Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant junit batchtest from a jar

Tags:

junit

ant

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.

like image 458
JasonPlutext Avatar asked Jul 08 '11 02:07

JasonPlutext


People also ask

How do I run a jar file from JUnit?

Download Link jar, it is not necessary to download other Hamcrest jars like Hamcrest-core. jar. Add the location where the four jar files are downloaded to the Classpath (or Path). Now that the build setup is complete, you can compile JUnit tests and execute the tests on the terminal.

How do you skip test cases in ant build?

If your project's build file is constructed like that, then it's a matter of running ANT with the compile target and that will skip the tests. If it isn't built like that then there is no other way than to change the build file and separate the unit tests into it's own target that is not the default.


1 Answers

Instead of zipentry you can probably use the zipfileset datatype:

<zipfileset src="tests-only.jar" includes="**/*Test.class"/>
like image 61
Ben Avatar answered Sep 30 '22 18:09

Ben