通过命令行使用黄瓜功能文件的标签对Gradle项目执行黄瓜测试执行 [英] Cucumber Test execution for gradle project via command line using tags for cucumber feature files
问题描述
我希望通过命令行使用特定功能标签对gradle项目执行黄瓜测试.
我正在使用的命令: gradle test -DCucumber.options =-tags @tagname"
命令确实执行提到的标签.我已经尝试过使用gradle test -DCucumber.options =-tags @tagname"
和 gradle test
.在这两个命令中我都没有发现任何区别.>
gradle test -DCucumber.options =-tags @tagname"
:执行Runtest.java和此文件中提到的标签,无论我通过命令行传递了哪些功能标签,例如:tagename.
Runtest.java
@RunWith(Cucumber.class)@CucumberOptions(features ="src \\ test \\ resources \\ featurefiles",单色= true,插件= {"com.eis.listeners.ExtentCucumberFormatter:"},胶= {"com.adminconsole.stepdefs"},tags = {"@ adminconsolelogin,@ devicemanager,@ certificatemanagement"},format = {"json:JsonReports/AdminConsole.json"})
因此,在这里我提到了Runtest.java中的三个标签.现在,我不想运行所有标签,而是想通过命令行运行特定的标签.命令: gradle test -DCucumber.options =-标签@adminconsolelogin"
,但是 -DCucumber.options =-tags @adminconsolelogin"
部分无效.>
我正在寻找一种解决方案,无论Runtest.java中提到了什么标签,我们都可以运行特定的标签.更精确地通过命令行动态传递标签.
但是, -DCucumber.options =-tags @tagname"
无法通过命令行运行.如果以下命令是错误的,那么任何人都可以向我提供正确的命令或策略或代码,请执行以下操作: gradle test -DCucumber.options =-tags @tagname"
请纠正我
您必须在gradle JVM和分叉JVM之间架起系统属性,才能进行测试.从问题#1346 :
测试{systemProperty"cucumber.options",System.getProperty("cucumber.options")}
将其添加到build.gradle中,然后可以在命令行上完成该操作:
等级测试-Dcucumber.options =-tags @tagname"
I am looking to execute a cucumber test for a gradle project via command line using specific feature tags.
The command I am using : gradle test -DCucumber.options="-tags @tagname"
Command does execute the tags mentioned.
I have tried using gradle test -DCucumber.options="-tags @tagname"
and also gradle test
.I didn't find any difference in both the command.
gradle test -DCucumber.options="-tags @tagname"
: Executes the Runtest.java and tags mentioned in this file, irrespective of what feature tags I pass via command line forexample: tagename.
Runtest.java
@RunWith(Cucumber.class)
@CucumberOptions(features = "src\\test\\resources\\featurefiles", monochrome = true, plugin = {
"com.eis.listeners.ExtentCucumberFormatter:" }, glue = {
"com.adminconsole.stepdefs" },tags= {"@adminconsolelogin,@devicemanager,@certificatemanagement"} ,format = { "json:JsonReports/AdminConsole.json" })
So here I have mentioned three tags in the Runtest.java.
Now, instead of running all the tags, I wanna run a specific tag via command line.
Command: gradle test -DCucumber.options="-tags @adminconsolelogin"
but, -DCucumber.options="-tags @adminconsolelogin"
part ain't working.
I am looking for a solution where we can run specific tags irrespective of what tag is mentioned in Runtest.java. More precisely pass tags dynamically via command line.
But, -DCucumber.options="-tags @tagname"
ain't working via command line.
Would appreciate is anyone can provide me with correct command or strategy or code on how to do it, if the below command is wrong : gradle test -DCucumber.options="-tags @tagname"
please correct me.
You have to bridge the system properties between the gradle JVM and the forked JVM for the tests for this to work. From issue #1346:
test { systemProperty "cucumber.options", System.getProperty("cucumber.options") }
Add that to your build.gradle and then you can do it on the command-line:
gradle test -Dcucumber.options="-tags @tagname"
这篇关于通过命令行使用黄瓜功能文件的标签对Gradle项目执行黄瓜测试执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!