java - Cucumber - 无法使用运行器运行测试

标签 java cucumber cucumber-jvm

问题: 当尝试运行 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/

相关文章:

c# - 为什么要用容器来存放观察者?

java - 如何从一个方法中给出两种不同的数据类型

java - 需要生成QueryParam的getter和setter

java - 如何动态使用 Selenium 的 @FindBy?

eclipse - 1.0.14 版本后的cucumber-java 和cucumber-junit 不起作用

java - 如何解决通过selenium访问网页元素而不滚动页面的问题

java - 使用java在linux上触发adb命令

java - Cucumber Java (Maven) WebdriverManager (Bonigarcia) 无法从属性获取 URL

java - 从另一个主要方法使用 Main.run 运行 Cucumber 项目

java - 如何在 Eclipse 上安装 Cucumber-JVM