Adam Matan
Adam Matan

Reputation: 136499

How to print debug messages with Junit ant task?

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?

Upvotes: 0

Views: 1730

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328840

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.

Upvotes: 1

Related Questions