GRadle - if junits fail,the build is failing without executing the next test case

Hi

I am working on a multi module grails project which uses gradle or build.

Consider my project as below:

MainApp —>Project1 ---->Project2

Consider two projects are under the main project and there are some test files inside project 1 and 2. And, consider the test case fails in project 1.

When i execute the below command, it starts exectuing project 1 and the test case fails in project 1 and it stopped execution, it is not executing project 2. Can you let me know why.

gradle grails-test-app -PgrailsArgs=unit:

Thanks Smurf

That’s normal, expected behavior. Gradle executes a series of steps and stops when one fails.

Would you expect gradle to run your tests if the compile failed?

Obviously, it should fail if there is a compilation issue. But, I would like gradle to run all the junits irrespective of any pass/faulre results. This is because, it will have a test-result file, which shows in which test it failed.

Can you please let me know, if we can do that in gradle. How to contiue the build even if the junit test case fails.

http://forums.gradle.org/gradle/topics/new_feature_continue_execution_on_task_failure

But, is there a way that for compilation issue it fails and for junits it proceeds the execution

“When executed with --continue, Gradle will execute every task to be executed where all of the dependencies for that task completed without failure”… “For example, tests will not run if there is a compilation failure in the code under test”

http://www.gradle.org/docs/current/userguide/tutorial_gradle_command_line.html#sec:continue_build_on_failure

If you want everything else to fail normally, but to continue along with failing tests, then you can simply use

test.ignoreFailures true

, which can also be expressed this way:

test {
  ignoreFailures true
}

That would go into the individual build.gradle files you want it to take effect for, or you could configure it for allprojects, subprojects, or selectively based upon plugins.

allprojects {
  plugins.withType(JavaPlugin) {
    test {
      ignoreFailures true
    }
  }
}

-Spencer

1 Like