Define a gradle task to run a task with specific system properties

I am trying to create a gradle task to perform a test task with the specified system.properties, which I use for my Selenium tests

task firefox() << { System.setProperty('driver', 'firefox') tasks.clean.execute() tasks.test.execute() } 

This does not work. I appreciate any help to complete my built script!

+4
source share
1 answer

Task.execute() should never be called from a script assembly (bad things can happen if you do this). To call this method before Gradle. The way to set the system properties for the test task:

 test { systemProperty "driver", "firefox" } 

System.setProperty() will not have any effect, because tests are always executed in a separate JVM.

+7
source

Source: https://habr.com/ru/post/1500484/


All Articles