Gradle property ignoreFailures test

My build.gradlefile is as follows:

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

and a gradle.propertieswith

ignoreFailureProp=false

Upon execution, gradle clean buildunit test failures do not mark the assembly as unsuccessful.

I know that the default behavior is to fail the assembly, but I want to explicitly set it through the property in order to change it without changing the assembly file

+4
source share
2 answers

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

Instead, you can do this:

apply plugin: "java"

test {
    ignoreFailures = ignoreFailureProp.toBoolean()
}

That should work.

+4
source

, gradle.properties.

build.gradle :

apply plugin: "java"
...
test {
  ...
  ignoreFailures Boolean.getBoolean("test.ignoreFailures")
}

gradle -Dtest.ignoreFailures=true clean build, . , , true (case in-sensitive), (.. ).

+3

Source: https://habr.com/ru/post/1546105/


All Articles