【问题标题】:Unable to run Cucumber Tests using Tags through Maven无法通过 Maven 使用标签运行 Cucumber 测试
【发布时间】:2018-04-11 03:55:06
【问题描述】:

当我使用“Run as Junit Tests”运行黄瓜测试时,测试使用适当的标签正常运行。

当我使用“Maven”运行黄瓜测试时,测试运行正常带有适当的标签,前提是我在运行器类中提到了标签。

@Cucumber.Options(format={"pretty", html:target/cucumber","json:target/cucumber.json"},tags= {"@smokeTest"})

但我希望能够将标签作为参数提供给 mvn test 命令,以运行测试用例,并且我正在使用以下命令。

mvn test -Dcucumber.options="--tags @tagTest"

但不管我的标签如何,它都会运行所有测试用例。

当我使用命令 mvn test -Dcucumber.options="--tags @tagTest" 我在我的跑步者课上没有提到任何标签

@Cucumber.Options(format={"pretty",html:target/cucumber","json:target/cucumber.json"})

请让我知道我哪里出错了?

这是 runnerTest 代码:

import org.junit.runner.RunWith;
import cucumber.junit.Cucumber; 

@RunWith(Cucumber.class)

@Cucumber.Options(format={"pretty", "html:target/cucumber","json:target/cucumber.json"})

public class runnerTest {

}

附上

pom.xml

【问题讨论】:

  • 不确定这是否有帮助,但是当为 maven 命令提供选项时,它会覆盖 runner 类中提到的所有选项。
  • @Grasshopper 是的,所以我希望当我使用命令 test -Dcucumber.options="--tags @smokeTest" 时,它应该能够运行并仅触发一个测试用例带有标签smokeTest

标签: maven testing tags cucumber continuous-testing


【解决方案1】:

第一个问题是maven命令和cucumber的版本不兼容。参数“cucumber.options”是在 1.1.1 版中引入的(请参阅thread),但 POM 显示的是旧版本。该特定黄瓜版本上该功能的正确 maven 命令应该是:

mvn test -Dtags=@tagTest

但第二个问题是,似乎有一个 bug 具有该功能,直到版本 1.1.1 才完全修复,当时还引入了新参数。

所以解决方案似乎是升级到1.1.1+版本的黄瓜。

【讨论】:

  • 感谢@Andre Barbosa 的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-09
相关资源
最近更新 更多