Question

Consider the following junit ant target, abridged for readability:

<target name="junit-tests" depends="clean, compile-tests">
    <junit fork="true" showoutput= ...>

        <classpath>...</classpath>
        <formatter.../>
        <jvmarg value=.../>

        <echo message="${test.dist.dir}"/>

        <batchtest todir=...>
            <fileset dir="${test.dist.dir}">
                <include name="**/*Junit.class"/>
            </fileset>
        </batchtest>
    </junit>
</target>       

In order to have verbose debug output for the test.dist.dir variable, I copied the following line from another target in the build.xml file:

<echo message="${test.dist.dir}"/>

But within the junit test target, it fails with:

build.xml:94: junit doesn't support the nested "echo" element.

How do I print debug outputs from a Junit ant task?

Was it helpful?

Solution

Put it before the <junit> element:

<target name="junit-tests" depends="clean, compile-tests">
    <echo message="${test.dist.dir}"/>
    <junit fork="true" showoutput= ...>...

There is no point to move it inside since the value of the variable can't change.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top