获取 org.junit.runner.RunWith 不是 Cucumber 的注解类型
Getting org.junit.runner.RunWith is not an annotation type with Cucumber
我正在尝试在 Java(我是 Java 的初学者)中在 Intellij 中设置一个 Selenium + Cucumber 项目。这是我的 class 使用 Cucumber JUnit runner:
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
我不知道如何解决这个问题或发生了什么。请帮忙。
如果您选择将功能文件放在您的项目中,则不必提供绝对路径space。 功能文件夹的名称就足够了。
例如,如果您具有以下结构:
- 包装:Q43966680
- Class: 亚军
- 功能文件夹:q43966680
快照:
根据您在 @CucumberOptions
中的用例,您只需提及:
@RunWith(Cucumber.class)
@Cucumber.Options (features="q43966680")
public class RunTest {
}
我的项目路径中有多个 RunWith
类。修剪项目树后,它按预期工作。
我正在尝试在 Java(我是 Java 的初学者)中在 Intellij 中设置一个 Selenium + Cucumber 项目。这是我的 class 使用 Cucumber JUnit runner:
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
我不知道如何解决这个问题或发生了什么。请帮忙。
如果您选择将功能文件放在您的项目中,则不必提供绝对路径space。 功能文件夹的名称就足够了。
例如,如果您具有以下结构:
- 包装:Q43966680
- Class: 亚军
- 功能文件夹:q43966680
快照:
根据您在 @CucumberOptions
中的用例,您只需提及:
@RunWith(Cucumber.class)
@Cucumber.Options (features="q43966680")
public class RunTest {
}
我的项目路径中有多个 RunWith
类。修剪项目树后,它按预期工作。