【问题标题】:Cucumber - Unable to run tests using runnerCucumber - 无法使用运行器运行测试
【发布时间】:2018-01-26 14:11:50
【问题描述】:

问题: 当尝试运行 cucumber runner 类以测试特定测试(按标签)时,测试将不会运行。将收到以下消息:

    Feature: Homepage

Test ignored.

Test ignored.

  @Testone
  Scenario: whateves     # Homepage_TC.feature:4
    Given printsomething

1 Scenarios (1 undefined)
1 Steps (1 undefined)
0m0.000s


You can implement missing steps with the snippets below:

@Given("^printsomething$")
public void printsomething() throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}


Process finished with exit code 0

运行功能文件就可以了。您可以在下面找到跑步者。

@CucumberOptions(features = "src/INGPSD2/main/resources/",
                 format = {"pretty", "html:target/cucumber",},
                glue = "src/INGPSD2/test/java/Steps",
                 tags = {"@Testone"})
@RunWith(Cucumber.class)
public class runnerCucumber { }

钩子类:

public class Hooks {
private static List<DriverFactory> webDriverThreadPool = Collections.synchronizedList(new ArrayList<DriverFactory>());
private static ThreadLocal<DriverFactory> driverFactory;
public SoftAssert softAssert = new SoftAssert();

@Before
public static void instantiateDriverObject() {
    driverFactory = new ThreadLocal<DriverFactory>() {
        @Override
        protected DriverFactory initialValue() {
            DriverFactory driverFactory = new DriverFactory();
            webDriverThreadPool.add(driverFactory);
            return driverFactory;
        }
    };
}

public static WebDriver getDriver() throws Exception {
        return driverFactory.get().getDriver();

}

// ----------------- SETUP

// -----------------------

@After
public static void closeDriverObjects() throws Exception {
    getDriver().manage().deleteAllCookies();
    for (DriverFactory driverFactory : webDriverThreadPool) {
        driverFactory.quitDriver();
    }
}

}

如果我能提供更多信息,请告诉我,因为这个问题真的很烦人,我找不到任何可以帮助的东西。

【问题讨论】:

  • 似乎跑步者无法找到“Given printsomething”的步骤定义。 runner 类上@CucumberOptions 上的胶水应该是步骤定义所在的包名。
  • 添加了 glue = "src/INGPSD2/test/java/Steps/_GeneralSteps" 还是同样的问题
  • 试试glue = "INGPSD2/test/java/Steps"?
  • @GeorgeCodreanu 这不是我要找的包名。步骤定义类在哪个包中声明?

标签: java cucumber cucumber-jvm


【解决方案1】:

你有一个错误定义glue。您应该使用包名而不是 steps.java 的路径。
所以改变 glue = "src/INGPSD2/test/java/Steps"glue = "package_name" 你的班级所在的位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-11
    • 2020-03-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多