我正在寻找一种解决方案,无论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项目执行黄瓜测试执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-05 04:26