0

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

同样,当我使用“ Maven”运行黄瓜测试时,测试使用适当的标签可以正常运行,前提是我在 runner 类中提到了标签。

@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

4

1 回答 1

1

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

mvn test -Dtags=@tagTest

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

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

于 2017-11-01T21:54:37.067 回答