Can't get build to fail with junit, ant, and cruisecontrol

Can't get build to fail with junit, ant, and cruisecontrol

Post by davi » Thu, 17 Apr 2003 10:51:47



I'm using CruiseControl and Ant to perform these steps:

1)clean-build
2)start weblogic server
3)run unit tests and reports
4)shutdown weblogic
5)send email if build fails, which i want to include unit tests
with failures, or errors

everything works fine, except the unit tests will not cause the build
to fail
even though i use the fail task if failureproperty is set in the junit
task.

if a target fails, shouldn't the build?

here's the skeleton for my CC-build.xml and my main project's
build.xml

******* the target called in CruiseControl-build.xml*************

<target name="clean-build-test"  depends="clean,vssget" >
    <ant antfile="${vss.local.path}/build/build.xml"
target="build-all-test"       inheritall="true" />
 <antcall target="labelbuild" />
</target>

************* target called = "build-all-test" *********************

<project name="Main Build Script" default="build" basedir="..">

[targets]
  <target name="test" >

        <junit haltonfailure="on" printsummary="true"
              fork="yes"    
              failureproperty="unit.test.failure"    
errorproperty="unit.test.failure" >

         </junit>

         <junitreport  .>

          </junitreport>

    </target>

[targets]

  <target name="build-all-test" depends="init"
                     description="runs build-all, starts WLS,  runs
tests, and shuts down WLS">

           <antcall target="build-all"/>
           <parallel>
                   <antcall target="startWebLogic"/>
                    <sequential >
                        <sleep seconds="120"/>
                        <antcall target="test"/>
                        <antcall target="shutdownWebLogic"/>
                    </sequential>
           </parallel>
        <fail if="unit.test.failure"></fail>
     </target>

</project>

 
 
 

1. Did anyone use 'batchtest' of ant's junit task?

Hi,
Did anyone use 'batchtest' of ant's junit task?

I'm using junit batchtest to run all the files **Test*.java using pattern
matching. Ant is running junit on these files and logging the test results to
files named TEST-name.txt for each matching file in the directory.

Suppose if there are 3 matching files SinpleTest.java, VectorTest.java, and
MoneyTest.java, the results are collected in 3 files TEST-SimpleTest.txt,
TEST-VectorTest.txt, and TEST-MonetTest.txt.

Is there a way to collect the results of all the tests in a single
"results.txt" file instead of ant creating one results file for each matching
file?

Ant is not allowing me to put the attribute "outfile=results.txt" either in
the 'fileset' or in the 'batchtest' tags.

Please help!  Thank You so much!

regards,
Kris

My build file is given below:

<?xml version="1.0"?> <project name = "Ant_Test" default="test" basedir=".">
<property name="classpath"
value=".;C:\jdk1.3\jre\lib\rt.jar;C:\jdk1.3\jre\lib\jaws.jar;C:\jdk1.3\jre\li
b\i18n.jar;C:\jdk1.3\lib\tools.jar;C:\junit3.2\j
unit.jar;C:\JavaWork\.;C:\jBoss\examples\interest\.;C:\junit3.2\.;C:\ant\lib\
ant.jar;C:\ant\lib\jaxp.jar;C:\ant\lib\pars
er.jar;C:\ant\lib\optional.jar;C:\ant\.;" />

<property name="srcdir" value="ant" />

<target name="test">
<junit printsummary="yes" haltonfailure="no">

<classpath>     <pathelement location="${srcdir}" />
                <pathelement path="${classpath}" />
</classpath>

<formatter type="plain" /> <!-- <test name="junit.samples.SimpleTest"
haltonfailure="no" outfile="Test_results"> </test> -->

<batchtest fork="yes">
        <fileset dir="${srcdir}" excludes="**\src\**">
                <include name="**/*Test*.java" />
                <exclude name="**/AllTests.java" />

        </fileset>

</batchtest>

</junit>

Sent via Deja.com
http://www.deja.com/

2. Streaming Video with Windows Media Player

3. JUnit 3.7 and Ant 1.4 Property definitions - don't work

4. plotting to lpt1

5. Did anyone use Ant's junit task?

6. dots&boxes on torus

7. Cruisecontrol continuous integration wrapper for Ant

8. FWP

9. Test cases organization (JUnit, Ant...)

10. JUnit + Ant + lazy developers

11. Test cases organization (JUnit, Ant...)

12. Ant build files and c++