Varun
Varun

Reputation: 123

Fail ant build by checking junit report?

I need to cause my build to fail based only on the junit report. Is there a way to do this. I know how to fail the build using haltonfailure in junit tag, but in my build.xml I have access only to the junit report. I am using ant.

Upvotes: 0

Views: 79

Answers (2)

user3139488
user3139488

Reputation:

Refer to this: http://ant.apache.org/manual/Tasks/junit.html ,

try using failureproperty="failed.unit.test.property" inside junit ant task & check if its set & fail when your run completes with :

<fail if="failed.unit.test.property" message="Unit tests failed with more custom msg to your test class/suite"/>

Upvotes: 1

azurefrog
azurefrog

Reputation: 10945

Try something like

    <fail if="testFail" message="At least one unit test failed"/>

in your unit test target.

Upvotes: 1

Related Questions