I am trying to configure two different gradle test tasks that essentially just set some values and then run the built-in test task. I have read the gradle documentation and have been searching for a few hours with no luck. I'm guessing I just don't know how to word this question properly to find anything.

The scenario is that we have selenium tests that we might want to run locally or remotely. If we run them locally we want to configure how many threads it uses, and if we run them remotely we want to set a much higher number of threads and also a system property so that the test runner knows to run remotely.

Essentially here's what I'd like to do:

task testLocal {
    maxParallelForks = 2
    // now run the built-in test task
}

task testRemote {
    maxParallelForks = 4
    systemProperties "geb.env": "winxp-firefox"
    // now run the built-in test task
}

Ideally I'd also like to be able to pass all the same arguments that the test task supports on the command line, like:

gradle testLocal --tests com.domain.tests.package*

What is the proper way to handle this scenario with gradle?

有帮助吗?

解决方案

The proper way to handle this is to have two Test tasks. You'd typically use (and configure) the Java plugin's test task for the local testing, and additionally declare and configure a second testRemote task (task testRemote(type: Test) { ... }). (There is no way to "wrap" a task, or "call" a task from another task.)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top