获取org.junit.runner.RunWith不是Cucumber的注释类型

问题描述 投票:2回答:2

我正试图在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

我不知道如何解决这个或正在发生的事情。请帮忙。

selenium intellij-idea junit cucumber cucumber-junit
2个回答
0
投票

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

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

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

快照:

Runner_new

根据您在qazxsw poi中的用例,您只需要提及:

@CucumberOptions

0
投票

我的项目路径中有多个@RunWith(Cucumber.class) @Cucumber.Options (features="q43966680") public class RunTest { } 类。修剪项目树后,它按预期工作。

© www.soinside.com 2019 - 2024. All rights reserved.