facewindu facewindu - 2 months ago 29
Java Question

gradle ignoreFailures test property

My

build.gradle
file is like the following :

apply plugin: "java"
...
test {
...
ignoreFailures = "$ignoreFailureProp"
}


and a
gradle.properties
with

ignoreFailureProp=false


When executed
gradle clean build
, the unit test failures do not mark the build as failed.

I know the default behaviour is to fail the build, but I want to explicitly set it through a property, to change in without modifying the build file

Answer

The problem is that ignoreFailureProp property is a string so the ignoreFailures (which should be a boolean) is set as a string and therefore will always be true.

You could do this instead:

apply plugin: "java"

test {
    ignoreFailures = ignoreFailureProp.toBoolean()
}

This should work.

Comments