将jvm参数传递给Gradle测试任务 [英] Passing jvm arguments to Gradle test task
问题描述
我想将JVM参数传递给我的Gradle测试任务。我在黄瓜功能文件中使用参数: $ {app.url}
。在 build.gradle
文件中,我输入了以下几行:
I would like to pass JVM parameters to my Gradle test task. I use the parameters in a Cucumber feature file: ${app.url}
. In the build.gradle
file, I put those lines:
test {
testLogging.showStandardStreams = true
systemProperties System.getProperties()
}
当我执行 gradle test -Dapp.url = http:// .....
时,我看不到参数已传递给应用程序。我也尝试了下面的方法,但是结果是相同的:
When I execute gradle test -Dapp.url=http://.....
, I don't see the parameter was passed to the application. I also tried the below, but the result is the same:
test {
testLogging.showStandardStreams = true
systemProperty "app.url", System.getProperty("app.url")
}
当我使用Maven并传递与Jvm参数相同的参数时,它可以正常工作。现在,我想切换到Gradle,但是我无法传递参数。
When I use Maven and pass the same parameters as Jvm arguments, it works fine. Now I would like to switch to the Gradle, but I am stuck with passing parameters.
推荐答案
gradle具有-P或- -project-prop选项。试试看这个。
gradle is having -P or --project-prop option. Try this one and see.
-P,--project-prop为构建脚本设置项目属性
-P, --project-prop Set project property for the build script
这篇关于将jvm参数传递给Gradle测试任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!