开发者

Layout of Ant build.xml with junit tests

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>
</target>

And I hav开发者_如何学Goe 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>


Publish test .class files into a separate directory, add this directory to <junit> task class path and scan that secondary directory for **/*Test.class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜