ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: JUnit tests fail -> build fail
Date Fri, 03 Aug 2001 08:38:19 GMT
On Fri, 3 Aug 2001, Klara Ward <klara.ward@debitech.com> wrote:

> Feel like giving me a short example of how to use it?

Say your main target that builds everything, runs the tests and
formats reports used to be "main".  Rename that target to real-main
and add a target like this:

<target name="main" depends="real-main" if="tests-failed">
  <fail message="At least one test has failed" />
</target>

and in your junit tasks add the attribute
errorproperty="tests-failed".

You still run the target main, as you used to do, all your stuff will
build and be tested as usual.  If one of the unit test fails, the
property tests-failed will be set (but all tests will be run) -
otherwise the property will not be defined.

When the main target is reached, it will either be skipped (resulting
in BUILD SUCCESSFUL) or a BuildException with the given method will be
thrown, which will give you a BUILD FAILED.

Stefan

Mime
View raw message