Layout of Ant build.xml with junit tests

Posted by Derk on Stack Overflow See other posts from Stack Overflow or by Derk
Published on 2010-04-20T17:33:17Z Indexed on 2010/04/20 17:53 UTC
Read the original article Hit count: 375

Filed under:
|
|

In a project I have a folder src for all application source code and a different folder test for all junit test (both with a simular package hierarchy).

Now I want that Ant can run all tests in in test folder, bot the problem is that now also files in the src folder with "Test" in the filename are included.

This is the test target in the build.xml:

<target name="test" depends="build">
    <mkdir dir="reports/tests" />
    <junit fork="yes" printsummary="yes">
    <formatter type="xml"/>
    <classpath>
        <path location="${build}/WEB-INF/classes"/>
        <fileset dir="${projectname.home}/lib">
            <include name="servlet-api.jar"/>
            <include name="httpunit.jar"/>
            <include name="Tidy.jar"/>
            <include name="js.jar"/>
            <include name="junit.jar"/>
        </fileset>
    </classpath>
    <batchtest todir="reports/tests">
        <fileset dir="${build}/WEB-INF/classes">
            <include name="**/*Test.class"/>
        </fileset>
    </batchtest>
</junit>

And I have added the test folder to the build target:

<target name="build" depends="init,init-props,prepare">
    <javac source="1.5" debug="true" destdir="${build}/WEB-INF/classes">
        <src path="src" />
        <src path="test" />
        <classpath refid="classpath"/>
    </javac>
</target>

© Stack Overflow or respective owner

Related posts about java

Related posts about ant