我创建了一个 RunTest 类来使用 Cucumber 和 JUnit 运行我的测试场景。要在之前运行测试,我需要将 RunWith 类 (@RunWith) 导入到我的项目中,并将 Cucumber.class 作为参数传递。然后,类的 RunWith 参数识别更多传递给它的参数,不。日食显示消息:
此行有多个标记 - 无法将类解析为类型。 - 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>
原文由 Kakashi - Sensei 发布,翻译遵循 CC BY-SA 4.0 许可协议
我在 IntelliJ idea 中也遇到了同样的问题,当我检查导入的库时,它就像下面的截图一样。
所以我从 pom 文件中的导入中删除了范围标记。然后它就起作用了。
早些时候
使固定
现在它工作正常