jayunit100
jayunit100

Reputation: 17648

How can I "fail" a build without halting in ant?

Hi : I hava an ANT build which fails, and halts on failure. I want the build to (rather than halting on failure of a single unit test), finish running ALL unit tests, so that I can know which ones passed/failed.

Then (of course), I want the build to ultimately fail, printing out the number of failed tests.

Oddly, it appears that "haltonfailure", does more then "halt" the build : it actually changes the Success/Failure outcome as interpretted by Jenkins !

I would like to , if possible, use the custom "fail" tag to make this clear in my build script, i.e. something like :

    <fail message="Some test(s) failed !">
      <condition>
         <not>
          <testFailures>0</testFailures>
         </not>
      </condition>  </fail>

Upvotes: 4

Views: 409

Answers (1)

Nialscorva
Nialscorva

Reputation: 2984

The failureproperty attribute on the Junit task and a conditional fail works well. I use it for generating the junit html reports even if the tests fail.

<junit failureproperty="junit.failed" haltonfailure="no">
   <!--- stuff -->
</junit>
<!-- Generate junit reports, pmd, coverage, etc -->
<fail if="junit.failed" message="Failed tests"/>

Upvotes: 9

Related Questions