Stop test/build execution on first failure and flag build as failed

Hello,

I have some long running integration tests and I would like these tests to make the build fail ‘fast’. Currently, if I have a failure, the test task still attempts to execute the remaining tests. Only after all of them executed, I get the build failure.

How can I make it so when I have a failure, everything stops there and the build is flagged failed right after the first failure?

I tried this one, but still can not stop gradle

afterTest { desc, result ->
         println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
        if (${result.resultType} == 'FAILURE'){
          throw new GradleException("Test failed!")
         }

This is not yet supported by gradle. You can vote for this feature at GRADLE-1518 regards, René

Thanks a lot

Note that this is now possible in Gradle 4.6. See https://docs.gradle.org/4.6/userguide/java_plugin.html#sec:test_execution