简体   繁体   English

无法通过Maven使用标签运行黄瓜测试

[英]Unable to run Cucumber Tests using Tags through Maven

when i run cucumber tests using "Run as Junit Tests", the tests runs properly with proper tags. 当我使用“作为Junit测试运行”运行黄瓜测试时,这些测试可以使用适当的标签正常运行。

also when i run cucumber tests using " Maven", the tests runs properly with proper tags,provided i have mentioned the tags in runner class. 同样,当我使用“ Maven”运行黄瓜测试时,只要我在转轮类中提到了这些标签,这些测试就可以使用适当的标签正常运行

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

But i want to be able to provide tags as argument to mvn test command,to run the test cases and i am making use of following command. 但是我希望能够提供标签作为mvn test命令的参数,以运行测试用例,并且我正在使用以下命令。

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

But it runs all the test cases irrespective of my tags. 但是,不管我的标签如何,它都会运行所有测试用例。

also when i use the command mvn test -Dcucumber.options="--tags @tagTest" i mention no tags in my runner class 另外,当我使用命令mvn test -Dcucumber.options="--tags @tagTest"我在跑步者类中没有提到任何标签

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

Please let me know where am i going wrong anywhere? 请让我知道我哪里哪里出问题了?

This is runnerTest code: 这是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 {

}

Attached 附上

pom.xml pom.xml

The first issue is that the maven command is not compatible with the version of cucumber. 第一个问题是maven命令与黄瓜版本不兼容。 The argument "cucumber.options" was introduced in version 1.1.1 (please see this thread ) but the POM shows an older version. 自变量“ cucumber.options”是在1.1.1版本中引入的(请参阅此线程 ),但POM显示的是旧版本。 The correct maven command for that feature on that specific cucumber version should be: 该特定黄瓜版本上该功能的正确maven命令应为:

mvn test -Dtags=@tagTest

But the second issue is that there seems to be a bug with that feature which was not fixed at all until version 1.1.1, which is when the new argument was also introduced. 但是第二个问题是,该功能似乎存在一个错误 ,该错误直到1.1.1版才被完全修复,也就是引入了新参数的时候。

So the solution seems to be to upgrade to version 1.1.1+ of cucumber. 因此,解决方案似乎是升级到黄瓜的1.1.1+版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM