Java Cucumber Runner类未运行步骤定义
我正在用Cucumber和Java编写自动化测试 我可以通过右键单击功能文件并将其作为Cucumber功能运行来运行步骤定义,所有步骤都成功通过 但是,我需要使用Runner类运行它们 我的功能文件在此文件夹中: src/test/java/features 我的步骤定义位于此文件夹中: src\test\java\com\abc\commercial\def\automation 我的Runner类也存储在 src\test\java\com\abc\commercial\def\automation 下面是Runner类代码:Java Cucumber Runner类未运行步骤定义,java,cucumber,gherkin,Java,Cucumber,Gherkin,我正在用Cucumber和Java编写自动化测试 我可以通过右键单击功能文件并将其作为Cucumber功能运行来运行步骤定义,所有步骤都成功通过 但是,我需要使用Runner类运行它们 我的功能文件在此文件夹中: src/test/java/features 我的步骤定义位于此文件夹中: src\test\java\com\abc\commercial\def\automation 我的Runner类也存储在 src\test\java\com\abc\commercial\def\automa
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"progress",
"html:build/report/html",
"junit:build/report/junit/cucumber-report.xml",
"json:build/report/json/cucumber-report.json"
},
glue = {"src\\test\\java\\com\\abc\\commercial\\def\\automation"},
features = {"src/test/java/features"}
)
public class QARunner {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
当我将Runner类作为JUnit测试运行时,我在控制台中收到以下响应:
UUUUUUUUU
Undefined scenarios:
src/test/java/features/US46052
src/test/java/features/postFeatures.feature:43 # As the
2 Scenarios (2 undefined)
9 Steps (9 undefined)
0m0.303s
You can implement missing steps with the snippets below:
@Given("the Application...")
public void the_Application...() {
因此,没有拾取步骤定义
这与我的测试跑步者所在的位置有关吗?
我不认为它在自动文件夹中获取步骤定义
感谢您的帮助试试这个:不需要main方法<代码>粘合选项应为包装样式
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"progress",
"html:build/report/html",
"junit:build/report/junit/cucumber-report.xml",
"json:build/report/json/cucumber-report.json"
},
glue = {"com.abc.commercial.def.automation"},
features = {"src/test/java/features"}
)
public class QARunner {
}
谢谢你的回答。这使得Runner类作为JUnit pass运行。但是,我现在需要以Gradle测试的形式运行Runner类。当我将main方法留在类中时,Gradle测试运行时没有错误。但是,当我查看目标文件夹中的测试报告时,没有运行任何测试?我不知道gradle与cucumber的关系