Ant JUnit Batchtest.java or .class

I saw some links that seem to imply that JUnit tests can be run from a .java file, not a .class

for instance

<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

 <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 to work due to ClassNotFoundExceptions

+6
source share
1 answer

I agree with the comment above that it looks like a tag that allows either .java or .class.

I did a little test, and when I checked the test with this installation - where dir=somefolder , and then using <include name="**/*Test.java"/> , when the folder containing the class files is specified, then Ant will basically have an empty set of files for processing for * Test.java, but when using <include name="**/*Test.class"/> set of files was not empty, and test cases will be launched.

This was the result of my quick test. As far as I can tell, it looks like you need to specify * Test.class to pick up the test cases.

+3
source

All Articles