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.
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.
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.
Instead of zipentry
you can probably use the zipfileset
datatype:
<zipfileset src="tests-only.jar" includes="**/*Test.class"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With