问题: 当尝试运行 Cucumber 运行程序类以测试特定测试(按标记)时,测试将不会运行。将收到以下消息:
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 { }
Hook 类:
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();
}
}
}
如果我可以提供更多信息,请告诉我,因为这个问题真的很烦人,而且我还找不到任何可以帮助的内容。
最佳答案
您定义glue
时出错。您应该使用包名称而不是 steps.java
的路径。
所以改变
glue = "src/INGPSD2/test/java/Steps"
到包含步骤的类所在的 glue = "package_name"
。
关于java - Cucumber - 无法使用运行器运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48463024/