I’m not super familiar with ant, but I’m trying to get some unit tests to run in my build process with it and running into issues. The build runs 100% without including the unit test.
I’m very confused with what I’m doing wrong here. When I echo out the classpath I make above with the same steps, it prints out a list that has my test
<path id="testPath.classpath">
<fileset dir="${dependencies}">
<include name="**/*.jar"/>
<include name="test/*.jar"/>
</fileset>
<fileset dir="${outDirectory}/" includes="**/**Test**.class" />
</path>
<pathconvert property="classpathProp" refid="testPath.classpath"/>
<echo>Classpath is ${classpathProp}</echo>
<junit printsummary="yes" haltonfailure="yes">
<formatter type="plain" usefile="false" />
<formatter type="plain" />
<classpath>
<fileset dir="${dependencies}">
<include name="**/*.jar"/>
<include name="test/*.jar"/>
</fileset>
<fileset dir="${outDirectory}/" includes="**/**Test**.class" />
</classpath>
<batchtest>
<fileset dir="${outDirectory}/path/to/test/classes/" includes="**/**Test**.class" />
</batchtest>
</junit>
However, I keep getting this error even though I see TestName.class in the classpath printout. I have no idea what I’m doing wrong here.
using junit4, ant 1.9.1
[junit] Running TestName
[junit] Testsuite: TestName
[junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
[junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
[junit]
[junit] Caused an ERROR
[junit] TestName
[junit] java.lang.ClassNotFoundException: TestName
[junit] at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[junit] at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:348)
[junit]
I’ve read through the docs here: https://ant.apache.org/manual/using.html#path
And have tried pretty much every combination of configuration and gotten no further than where I’m at currently.
1