ant junit batchtest from a jar

2019-04-06 22:03发布

问题:

I'd like to use ant (post 1.7) to run all tests in classes named *Test.class in a certain jar.

Something like the following (although it doesn't actually run any tests):

    <junit fork="yes" printsummary="on" haltonfailure="on">
        <formatter type="xml"/>
        <batchtest fork="yes" todir="${junit.output.dir}">
            <resources>
               <zipentry zipfile="tests-only.jar" name="**/*Test.class"/>
            </resources> 
        </batchtest>            
        <classpath refid="testsplus.classpath"/>
    </junit>

What is the correct syntax for the resources/zipentry part?

The ant docs say:

batchtest collects the included resources from any number of nested Resource Collections. It then generates a test class name for each resource that ends in .java or .class.

Any type of Resource Collection is supported as a nested element, prior to Ant 1.7 only <fileset> has been supported.

回答1:

Instead of zipentry you can probably use the zipfileset datatype:

<zipfileset src="tests-only.jar" includes="**/*Test.class"/>


标签: ant junit