我正在使用cucumber
和selenium
项目,并且我正在尝试通过Junit Test Runner
运行测试。这是the complete code (确保您的 IDE 中有 lombok)。这是我的测试运行器
:
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/test/resources/features" },
monochrome = true,
plugin = {
"pretty",
"com.cucumber.listener.ExtentCucumberFormatter:target/report.html"
},
tags = {"@all"},
glue = {"stepDefinitions"}
)
public class TestRunnerJUnit {
@AfterClass
public static void setup() {
Reporter.setSystemInfo("User Name", System.getProperty("user.name"));
Reporter.setSystemInfo("Time Zone", System.getProperty("user.timezone"));
Reporter.setSystemInfo("Machine", "Windows 10" + "64 Bit");
Reporter.setTestRunnerOutput("Sample test runner output message");
}
}
重点是,当我使用测试运行程序运行测试时,它找到了功能文件,但在其中找不到任何场景。这是运行的输出:
@all
Feature:
As a customer, I should be able to register for insurance.
0 Scenarios
0 Steps
0m0.000s
如果我直接使用功能文件运行测试(通过右键单击它作为 Cucumber 运行
,那么它运行良好。但是,我需要通过测试运行程序运行我的测试)
最佳答案
我有机会提取您的代码库并研究代码。 您遇到的问题与扩展库有关。 您在新行中提供功能名称,而哪个范围库无法理解这一点。在同一行写下功能名称,它应该可以解决您的问题
Feature: As a customer, I should be able to register for insurance.
我还建议您使用较新版本的 Cucumber (Cucumber-JVM v4+) 库,该库具有并发执行支持(在单个 JVM 下),并且您使用的当前库将根据您的配置跨越多个 JVM 实例
关于java - 为什么 Junit TestRunner 找不到功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59416697/