Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define gradle task, to run task with specific system properties

I am struggling to create a gradle task to execute the test task with specified system.properties that I use for my Selenium Tests

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

That does not work obviously. I highly appreciate any help, to finalize my built script!

like image 504
Mathias Maciossek Avatar asked Feb 15 '23 09:02

Mathias Maciossek


1 Answers

Task.execute() should never be called from a build script (bad things can happen if you do). It's up to Gradle to call this method. The way to set system properties for the test task is:

test {
    systemProperty "driver", "firefox"
}

System.setProperty() won't have any effect because tests always execute in a separate JVM.

like image 51
Peter Niederwieser Avatar answered May 08 '23 08:05

Peter Niederwieser