【问题标题】:Why Junit TestRunner cannot find the features?为什么 Junit TestRunner 找不到功能?
【发布时间】:2019-12-19 20:46:27
【问题描述】:

我正在使用cucumberselenium 项目,我正在尝试通过Junit Test Runner 运行测试。这是the complete code(确保你的IDE中有lombok)。这是我的test runner

@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

如果我直接使用功能文件运行测试(通过右键单击它Run as Cucumber 那么它运行良好。但是,我需要通过测试运行器运行我的测试)

【问题讨论】:

  • 尝试从功能文件中删除第二个@all

标签: java selenium junit cucumber test-runner


【解决方案1】:

我有机会提取您的代码库并查看代码。 您遇到的问题与范围库有关。 您在新行中提供功能名称,以及哪个范围库无法理解。在同一行写功能名称,它应该可以解决您的问题

Feature: As a customer, I should be able to register for insurance.

我还建议您使用具有并发执行支持(在单个 JVM 下)的较新版本的黄瓜 (Cucumber-JVM v4+) 库和您正在使用的当前库,这些库将根据您的配置跨越多个 JVM 实例

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-10
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    • 2021-12-08
    • 2019-12-21
    • 1970-01-01
    • 2014-04-06
    相关资源
    最近更新 更多