ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Klara Ward" <klara.w...@debitech.com>
Subject RE: JUnit tests fail -> build fail
Date Fri, 03 Aug 2001 15:27:41 GMT
It worked for me just as your example (except I have: Ant version 1.4alpha
compiled on August 2 2001 .. and I didn't get a stacktrace, only Wohoo!)

But....
If I try with batchtest..

<project default="without-fail">
  <target name="without-fail">
    <junit failureproperty="tests-failed">
	<batchtest>
	    <fileset dir=".">
	        <include name="Dummy.java" />
	    </fileset>
	</batchtest>
       <classpath location="." />
    </junit>
  </target>

  <target name="with-fail" depends="without-fail" if="tests-failed">
    <fail message="Wohoo!" />
  </target>
</project>


C:\anttest>ant -f junit.xml with-fail
Buildfile: junit.xml

without-fail:
    [junit] TEST Dummy FAILED

with-fail:

BUILD SUCCESSFUL

Total time: 2 seconds


So what do you think of this...

Klara


> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@apache.org]
> Sent: den 3 augusti 2001 13:30
> To: ant-user@jakarta.apache.org
> Subject: Re: JUnit tests fail -> build fail
>
>
> On Fri, 3 Aug 2001, Klara Ward <klara.ward@debitech.com> wrote:
>
> > I tried with failureproperty both in junit and batchtest and neither
> > of them worked.
>
> junit.xml
> =========
> <project default="without-fail">
>   <target name="without-fail">
>     <junit failureproperty="tests-failed">
>       <test name="Dummy" />
>       <classpath location="." />
>     </junit>
>   </target>
>
>   <target name="with-fail" depends="without-fail" if="tests-failed">
>     <fail message="Wohoo!" />
>   </target>
> </project>
>
> Dummy.java
> ==========
> import junit.framework.TestCase;
>
> public class Dummy extends TestCase {
>
>     public Dummy(String name) {
>         super(name);
>     }
>
>     public void test1() {
>         fail("I failed");
>     }
> }
>
> Shell output
> ============
> bodewig@bodewig /tmp/src >ant -version
> Ant version 1.4alpha compiled on August 3 2001
>
> bodewig@bodewig /tmp/src >ant -f junit.xml without-fail
> Buildfile: junit.xml
>
> without-fail:
>     [junit] TEST Dummy FAILED
>
> BUILD SUCCESSFUL
>
> Total time: 1 second
>
> bodewig@bodewig /tmp/src >ant -f junit.xml with-fail
> Buildfile: junit.xml
>
> without-fail:
>     [junit] TEST Dummy FAILED
>
> with-fail:
>
> BUILD FAILED
>
> /tmp/src/junit.xml:10: Wohoo!
> 	at java.lang.Throwable.<init>(Throwable.java:96)
> 	at java.lang.Exception.<init>(Exception.java:44)
> 	at java.lang.RuntimeException.<init>(RuntimeException.java:49)
> 	at
> org.apache.tools.ant.BuildException.<init>(BuildException.java:84)
> 	at org.apache.tools.ant.taskdefs.Exit.execute(Exit.java:74)
> 	at org.apache.tools.ant.Task.perform(Task.java:240)
> 	at org.apache.tools.ant.Target.execute(Target.java:164)
> 	at org.apache.tools.ant.Target.performTasks(Target.java:182)
> 	at org.apache.tools.ant.Project.executeTarget(Project.java:568)
> 	at org.apache.tools.ant.Project.executeTargets(Project.java:527)
> 	at org.apache.tools.ant.Main.runBuild(Main.java:453)
> 	at org.apache.tools.ant.Main.start(Main.java:154)
> 	at org.apache.tools.ant.Main.main(Main.java:177)
>
> Total time: 1 second
>
> Stefan
>


Mime
View raw message