Reputation: 64429
For building and running tests I'm using Ant. Testing works at the moment; it generates some output and a report (XML), but I can't use it in CI, as the exit-value is still something the builder is OK with, even if there is a failure.
How can I get a result on failure that will make the ci-runner understand it is an actual failure?
I'm using something like this (removed some classpath clutter):
<target name="junit">
<junit printsummary="yes">
<formatter type="xml"/>
<batchtest fork="yes" todir="${report.dir}">
<fileset dir="${test.dir}" includes="**/*Test.java"/>
</batchtest>
</junit>
</target>
I did find out I can add haltonfailure="yes"
to the <junit>
. This halts (and fails) the build, but then it doesn't run all tests.
I'd like to run all the tests, and in the end exit with a failure if there was one.
Upvotes: 0
Views: 1200
Reputation: 692231
You can use the errorproperty
and failureproperty
attributes of the junit task to set a property when an error/failure is detected, and then use the fail task to fail the build if one of these properties is set.
But my advice would be to stop using ant, and use gradle instead, which makes that kind of stuff much easier (it's done out of the box).
Upvotes: 2