views:

255

answers:

2

I have a number of tests failing in the following JUnit Task.

 <target name="test-main" depends="build.modules" description="Main Integration/Unit tests">
        <junit fork="yes"
               description="Main  Integration/Unit Tests"
               showoutput="true"
               printsummary="true"
               outputtoformatters="true">
            <classpath refid="test-main.runtime.classpath"/>
            <batchtest filtertrace="false" todir="${basedir}">
                <fileset dir="${basedir}" includes="**/*Test.class" excludes="**/*MapSimulationTest.class"/>
            </batchtest>
        </junit>
    </target>

How do I tell Junit to ouput the errors for each test so that I can look at the stack trace and debug the issues.

+2  A: 

The answer was to add the tag within the tag.

 <target name="test-main" depends="build.modules" description="Main Integration/Unit tests">
        <junit fork="yes"
               description="Main  Integration/Unit Tests"
               showoutput="true"
               printsummary="true"
               outputtoformatters="true">
            <classpath refid="test-main.runtime.classpath"/>
            <batchtest filtertrace="false">
                <fileset dir="${basedir}/out/test/common" includes="**/*Test.class" excludes="**/*MapSimulationTest.class"/>
                <fileset dir="${basedir}/out/test/test-simulation" includes="**/*Test.class" excludes="**/*MapSimulationTest.class"/>
            </batchtest>
            <formatter type="brief" usefile="false"/>
        </junit>
    </target>
Benju
+2  A: 

You'll need to add the formatter task as a child of the batchtest task (NOT as the immediate child of the junit task)

The syntax of formatter is:

<formatter type="plain" usefile="false"/>

type can be one of plain, brief, xml or failure.

usefile="false" asks Ant to send output to the console.

Scroll down to the h4 on "formatters" at http://ant.apache.org/manual/OptionalTasks/junit.html for more details.

Hippo