I have seen a few links which appears to imply that JUnit tests can be executed from the .java file instead of the .class
For example
<junit printsummary="yes" haltonfailure="yes" haltonerror="yes">
<classpath refid="ui.tests.classpath"/>
<formatter type="xml"/>
<batchtest todir="${env.WORKSPACE}/UITests/output">
<fileset dir="${ui.tests.classes}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
Instead of
<junit printsummary="yes" haltonfailure="yes" haltonerror="yes">
<classpath refid="ui.tests.classpath"/>
<formatter type="xml"/>
<batchtest todir="${env.WORKSPACE}/UITests/output">
<fileset dir="${ui.tests.classes}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
Is the first example a valid case? I could not get it working due to ClassNotFoundExceptions
This task is used to run tests from the JUnit testing framework. This task is depend on external libraries that are not included in Apache Ant distribution by default. The junit. jar and ant.
The use of Ant makes it straight forward through the JUnit task.
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.
I agree with the comment above, that it looks like the tag allows for either .java or .class.
I did a small test and when I ran a test with this setup - where the dir=somefolder
, then using <include name="**/*Test.java"/>
when the folder pointed at contains class files, then Ant will basically have an empty fileset to process for *Test.java, but when using <include name="**/*Test.class"/>
then the fileset was not empty and the test cases will get run.
This was the result of my quick test. As far as I could tell, it looks like you need to specify the *Test.class to pickup the test cases.
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