当我以下列方式传递标签时,它的效果非常好。
package features
import org.junit.runner.RunWith
import cucumber.junit.Cucumber
import geb.junit4.GebReportingTest
@RunWith(Cucumber.class)
@Cucumber.Options(format = ["pretty", "html:build/cucumber", "json-pretty:build/cucumber-report.json"])
,tags = ["@login_neg"])
class RunCukesSpec extends GebReportingTest {}
但我的目标是通过build.gradle
&如果成功则通过命令行。我尝试在下面作为初始步骤,并希望通过在命令行中运行gradle test
来获得预期的结果。
test {
testLogging.showStandardStreams = true
args = ['--tags', '@login_neg',
'--format', 'html:build/cucumber',
'--format', 'json-pretty:build/cucumber-report.json',
'--format', 'pretty']
}
在这种情况下,所有标签都在运行。
也试过这个。但没有运气
gradle test -DCucumber.Options="--tags @login_neg"
版本:
------------------------------------------------------------
Gradle 1.9
------------------------------------------------------------
Build time: 2013-11-19 08:20:02 UTC
Build number: none
Revision: 7970ec3503b4f5767ee1c1c69f8b4186c4763e3d
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy: 2.2.0
JVM: 1.7.0_45 (Oracle Corporation 24.45-b08)
OS: Windows 7 6.1 amd64
答案 0 :(得分:5)
您可以通过使用以下内容更新build.gradle
文件来将选项作为系统属性传递:
test {
systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
}
此配置会将cucumber.options
System属性从Gradle JVM传递给运行测试的JVM。
然后,您可以运行gradle test -Dcucumber.options="--help"
以查看该系统属性的可用选项(将--help
替换为您的选项)。