I don't think I got it to work.
my buildfile:
<target name="junittest" depends="init">
<delete dir="${testresults}"/>
<mkdir dir="${testresults}"/>
<junit errorproperty="tests-failed">
<formatter type="xml" />
<jvmarg value="-Dclassroot=${build}" />
and
<target name="test" depends="junittest" if="tests-failed">
<fail message="At least one test has failed" />
</target>.
started with ant test.
Output:
[snip]
[junit] TEST a.b.CTest FAILED
[junit] TEST a.b.DTest FAILED
main:
BUILD SUCCESSFUL
Total time: 1 minute 54 seconds
Any ideas?
Klara
> -----Original Message-----
> From: Stefan Bodewig [mailto:[EMAIL PROTECTED]]
> Sent: den 3 augusti 2001 08:38
> To: [EMAIL PROTECTED]
> Subject: Re: JUnit tests fail -> build fail
>
>
> On Fri, 3 Aug 2001, Klara Ward <[EMAIL PROTECTED]> 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
>