【问题标题】:Getting org.junit.runner.RunWith is not an annotation type with Cucumber获取 org.junit.runner.RunWith 不是 Cucumber 的注释类型
【发布时间】:2019-02-18 14:30:51
【问题描述】:

我正在尝试在 Intellij 中用 Java 设置 Selenium + Cucumber 项目(我是 Java 初学者)。这是我使用 Cucumber JUnit 跑步者的课程:

package runtest;

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

@RunWith(Cucumber.class)
@CucumberOptions (
        features = "C:\\Users\\my-feature.feature",
)

public class RunTest {

}

我收到以下错误:

Error:(8, 1) java: annotation @org.junit.runner.RunWith is missing default values for elements annotationType,<init>
Error:(8, 2) java: org.junit.runner.RunWith is not an annotation type

我不知道如何解决这个问题或发生了什么。请帮忙。

【问题讨论】:

  • 你在用pom.xml
  • 不,我没有使用它。

标签: selenium intellij-idea junit cucumber cucumber-junit


【解决方案1】:

我的项目路径中有多个 RunWith 类。修剪项目树后,它按预期工作。

【讨论】:

    【解决方案2】:

    如果您选择将其放置在您的项目空间中,则不必提供 功能文件绝对路径功能文件夹的名称就足够了。

    例如,如果您具有以下结构:

    • 包装:Q43966680
    • 类:跑步者
    • 功能文件夹:q43966680

    快照:

    根据您在@CucumberOptions 中的用例,您只需提及:

    @RunWith(Cucumber.class)
    @Cucumber.Options (features="q43966680")
    
    public class RunTest {
    
    }
    

    【讨论】:

    • 谢谢,这很有用,但它不能回答我的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 2018-07-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多