【问题标题】:The import cucumber cannot be resolved in Runner Class for Gradle ProjectGradle 项目的 Runner 类中无法解析导入黄瓜
【发布时间】:2019-05-20 11:33:09
【问题描述】:

我的 Gradle 依赖项没有什么问题,但是当我尝试导入 import cucumber.api.junit.Cucumber; 时出现错误 The import cucumber cannot be resolved

下面是我的 Gradle 文件:

apply plugin: 'java'

version = '1.0-SNAPSHOT'

dependencies {
    compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.5'
    testCompile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5'
    compile group: 'info.cukes', name: 'cucumber-core', version: '1.2.5'
    testCompile group: 'info.cukes', name: 'cucumber-picocontainer', version: '1.2.5'
    compile group: 'info.cukes', name: 'cucumber-guice', version: '1.2.5'
    testCompile group: 'junit', name: 'junit', version: '4.12'      
}

repositories {
    mavenCentral()
}

我的跑步者班级是:

package Runner;

import org.junit.runner.RunWith;
import cucumber.api.junit.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
Cucumber.options(
    features = "\\src\\test\\java\\Feature",
    glue = {"\\src\\main\\java\\Steps\\"},
    tags = {"@ignored"},
    format = {"json:target/cucumber/wikipedia.json","html:target/cucumber/wikipedia.html","pretty"}
)
public class RunnerMain {
}

当我评论 @RunWithCucumberOptions 并删除导入时,然后运行命令 gradle build 然后我看不到任何错误并且一切顺利。

我不知道我在这里做错了什么。

【问题讨论】:

    标签: gradle junit automation cucumber


    【解决方案1】:

    将 Cucumber.options 替换为 @CucumberOptions 并尝试一次

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-03
      • 1970-01-01
      • 1970-01-01
      • 2014-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多