ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alison Monteith" <alison.monte...@edusoft.com>
Subject Build not failing when Junit tests fail
Date Thu, 07 Oct 2004 21:17:21 GMT
Hi,
 
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"
failureproperty="junit_test_failed">
 
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
cruisecontrol)">
    <antcall target="run-tests">
        <param name="test.mask" value="Test"/>
    </antcall>
     </target>
 
---------------------------------------
  <target name="run-tests">
          -----------
        (snipped code)
           ----------
<foreach target="run-unit-test" param="test-name"
list="${rel.test.list}" />
<antcall target="junit-report"/>
 </target>
 
-----------------------------------------
<target name="run-unit-test">

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






 



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