ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alison Monteith" <>
Subject Build not failing when Junit tests fail
Date Thu, 07 Oct 2004 21:17:21 GMT
I'm pretty new to ant am trying to get our ant build to fail when any
junit test fails.
I've looked at our current build.xml and have found the following (which
appears to be correct):
target to run the tests contains:
 <junit printsummary="yes" fork="yes" haltonfailure="false"
later target contains:
<fail if="junit_test_failed" message="Junit test failure"/>
When I use the Ant -debug option the failureproperty value is being set
to junit_test_failed as expected, but for some reason the build being
reported as successful.  If I take out the if="junit_test_failed"
statement.  ie.
just have: <fail message="Junit test failure"/>  then the build fails.
I'm thinking that somehow the junit_test_failed property is not visible
at the time of the <fail> tag.  
There are a lot of <ant call> statements in my build.xml, and it's in
one of these calls that the property is being set.  Why is this
junit_test_failed not visible when the <fail> tag is being executed.  
Here's excepts from my build.xml, for more details:
 <target name="test-cc" depends="clean, init, compile, compile-test"
   description="Runs all JUnit tests and cleans (used for
    <antcall target="run-tests">
        <param name="test.mask" value="Test"/>
  <target name="run-tests">
        (snipped code)
<foreach target="run-unit-test" param="test-name"
list="${rel.test.list}" />
<antcall target="junit-report"/>
<target name="run-unit-test">

        (snipped code)
<junit printsummary="yes" fork="yes" haltonfailure="false"
     <jvmarg value="-Xdebug"/>
     <jvmarg value="-Xnoagent"/>
     <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n"/>
     <jvmarg value="-Djava.compiler=NONE"/>
       <pathelement location="${test.source}"/>
       <path refid="project.classpath"/>
     <batchtest todir="${test.reports}">
        <fileset dir="${test.source}">
           <include name="${test-name}"/>
        <formatter type="xml"/>
 <target name="junit-report">
    <junitreport todir="${test.reports}">
      <fileset dir="${test.reports}">
        <include name="TEST-*.xml" />
       <report todir="${test.reports}" />
  <fail if="junit_test_failed" message="Junit test failure"/> 
Any help would really be appreciated!


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message