【发布时间】:2018-12-11 14:11:31
【问题描述】:
我创建了一个 RunTest 类来使用 Cucumber 和 JUnit 运行我的测试场景。要在之前运行测试,我需要将 RunWith 类 (@RunWith) 导入到我的项目中,并将 Cucumber.class 作为参数传递。然后,类的 RunWith 参数识别更多传递给它的参数,不。 eclipse显示消息:
此行有多个标记 - 类无法解析为类型。 - Cucumber 无法解析为一个类型。 - 注解@RunWith 必须定义属性值
我正在使用 Maven 来组织我的 JARS 文件。 以下是代码和错误屏幕。
我的 POM.XML
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
</dependencies>
【问题讨论】:
-
您尝试过导入 Cucumber 吗?
-
确实,尝试添加
import cucumber.junit.Cucumber;。 -
是的。我试过了,但eclipse显示消息:无法解决import cucumber.junit。我想我的项目中缺少一些 JAR 文件。
-
在您的
pom.xml中,您有依赖关系info.cukes:cucumber-jvm:pom:1.2.5,它不在您的任何屏幕截图的依赖关系列表中。如果你在命令行上运行mvn compile会发生什么?我用你的pom.xml和RunTest.java创建了一个小项目,它编译得很好。
标签: java eclipse selenium cucumber