【问题标题】:How do i setup my Junit runner for cucumber to run on multiple projects?我如何设置我的 Junit 跑步者让黄瓜在多个项目上运行?
【发布时间】:2018-10-24 18:06:40
【问题描述】:

我最近开始使用黄瓜,我刚刚建立了项目 project setup

如您所见,我有 DefaultRunner.java,它是 JUnit 运行器类,它具有以下代码:

package Runners;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src\\test\\resources\\Features\\GreatCourse.feature",
        glue={"Steps"},
        format = {"pretty","html:target/cucumber"},
        tags= {"@smoke"}
        )

public class DefaultRunner {

}

现在我可以毫无问题地在 Windows 系统上运行它,但由于寻址系统的原因,我无法在 Mac 上运行它。我尝试使用 if 语句来选择操作系统,但它不起作用。

【问题讨论】:

  • 您得到的确切错误是什么?您是否尝试过: features = "src/test/resources/Features/GreatCourse.feature"?
  • 我可以使用它,但这意味着我只能在 Mac 上使用它,而不能在 Windows 机器上使用。我希望能够编写一行代码并能够在两台机器上使用它。

标签: api junit frameworks cucumber runner


【解决方案1】:

您也许可以使用“类路径”作为功能文件的位置,该文​​件也应该在 Windows 上运行:

package Runners;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
    features = "classpath:Features/GreatCourse.feature",
    glue={"Steps"},
    format = {"pretty","html:target/cucumber"},
    tags= {"@smoke"}
)

public class DefaultRunner {

}

我无法对此进行测试,因为我没有 Windows 机器,但应该可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-28
    相关资源
    最近更新 更多