I have the following task
task testGeb(type:Test) {
jvmArgs '-Dgeb.driver=firefox'
include "geb/**/*.class"
testReportDir = new File(testReportDir, "gebtests")
}
The system property doesn't appear to make it to the Geb tests, as Geb does not spawn Firefox to run the tests. When I set the same system property in Eclipse and run the tests, everything works fine.
-D is used to set properties. Properties are strings that can be read inside code and can be specified to the JVM in multiple ways, including this parameter. This parameter can be specified multiple times: one for each parameter/value combination that you want to pass to the program.
System properties contain information to configure the JVM and its environment. Some system properties are particularly relevant for JVMs in a CICS® environment. Specify JVM system properties in the JVM profile.
Try using system properties:
test {
systemProperties['geb.driver'] = 'firefox'
include "geb/**/*.class"
testReportDir = new File(testReportDir, "gebtests")
}
You can also directly set the system property in the task:
task testGeb(type:Test) {
System.setProperty('geb.driver', 'firefox')}
(the solution above will also work for task type different from Test
)
or if you would like to be able to pass different properties from the command line, you can include a more flexible solution in the task definition:
task testGeb(type:Test) {
jvmArgs project.gradle.startParameter.systemPropertiesArgs.entrySet().collect{"-D${it.key}=${it.value}"}
}
and then you can run:
./gradlew testGeb -D[anyArg]=[anyValue]
, in your case: ./gradlew testGeb -Dgeb.driver=firefox
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With