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 13:29:57 GMT
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