ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 肖谋 <xiao...@gmail.com>
Subject How to run a single junit test method with ant
Date Fri, 10 May 2013 04:33:04 GMT
Hi, Users.
   I am using ant in Linux. I can use ant junit task to run all test
methods in a junit4 test class but fail to find the way to  run a single
test method.  I googled and found a helpful article at
https://today.java.net/pub/a/today/2003/09/12/individual-test-cases.html.
However, the solution it provides does not help. My ant seems not to
recognize the "tests" sysproperty.
  My ant version is 1.8.4. and the related content of build.xml is listed
as follows:

   <target name="ensure-test-name" unless="test">
        <fail message="You must run this target with -Dtest=TestName"/>
    </target>

    <target name="run-general-test" description="Runs the test you specify
on the command
        line with -Dtest=" depends="compile, ensure-test-name">
        <junit printsummary="withOutAndErr" fork="true">
            <sysproperty key="tests" value="${tests}"/>
            <classpath refid="test.classpath" />
            <formatter type="plain" usefile="false"/>
            <batchtest>
                <fileset dir="${test.src.dir}">
                    <include name="**/${test}.java"/>
                </fileset>
            </batchtest>
        </junit>
    </target>

  Please help! Thanks a lot!

Regards
xiaomou

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message