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
You can do gradle -Dtest. single=ClassUnderTestTest test if you want to test single class or use regexp like gradle -Dtest. single=ClassName*Test test you can find more examples of filtering classes for tests under this link.
Within IntelliJ IDEA, find the check task in the Gradle tool window under verification. Double click it to run. Check is also run when you run the build task, thanks to a task dependency setup by the base plugin. Gradle runs the assemble task then check.
Use the command ./gradlew test to run all tests.
To skip any task from the Gradle build, we can use the -x or –exclude-task option. In this case, we'll use “-x test” to skip tests from the build. As a result, the test sources aren't compiled, and therefore, aren't executed.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With