黄瓜无法解析为类型

新手上路,请多包涵

我创建了一个 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 许可协议

阅读 284
1 个回答

我在 IntelliJ idea 中也遇到了同样的问题,当我检查导入的库时,它就像下面的截图一样。

截屏

所以我从 pom 文件中的导入中删除了范围标记。然后它就起作用了。

早些时候

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.5</version>
    <scope>test</scope>
</dependency>

使固定

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.5</version>
</dependency>

现在它工作正常

原文由 Sandunika Wijerathne 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题