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

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) {

forkEvery=1

maxParallelForks=1

} }

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

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 = System.properties['forkEvery'] ? System.properties['forkEvery'].toInteger() : 1
}

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