How do I override forEvery=1 on the command line when debugging?

(Russell Gold) #1

We have our unit tests running with forEvery=1 and maxParallelForks=4. But when we debug, we want those turned off. Is there a good way to do that from the command line? So far, I’ve been editing the build.gradle file, but that’s clumsy and might lead to somebody checking that in by mistake.

I tried:

test {

if (!debug) {



} }

in the build.gradle file, but setting -Dtest.debug=true on the command line didn’t prevent forkEvery from being set.

(Benjamin Muschko) #2

You can drive the value for every property from the command line via project or system properties. Here’s an example for using a system property:

test {
    forkEvery =['forkEvery'] ?['forkEvery'].toInteger() : 1

Please make sure to use the code tag to format code blocks in your questions.