Reputation: 725
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
Upvotes: 10
Views: 14395
Reputation: 4840
You do not have to use a file like gradle.properties
.
If you change your build.gradle
to:
apply plugin: "java"
...
test {
...
ignoreFailures Boolean.getBoolean("test.ignoreFailures")
}
and invoke the tests with gradle -Dtest.ignoreFailures=true clean build
you are done without editing any file. Note that, if you do not set the parameter or set it to any other value than true
(case in-sensitive) failures are not ignored (ie. the default behaviour).
Upvotes: 10
Reputation: 2536
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.
Upvotes: 8