Reputation: 315
I am currently trying to configure a build file to run junit test using ant xml file. However ClassNotFound Exception is being encountered. The following is part of the code that shall run the jUnit test:
<target name="junitreport" >
<junit printsummary="yes" haltonfailure="no">
<classpath refid="JUnit 4.libraryclasspath"/>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest todir="${junit.output.dir}">
<fileset dir="src/tests">
<include name="CalculatorTest.java"/>
</fileset>
</batchtest>
</junit>
</target>
How this can be solved?
Upvotes: 0
Views: 296
Reputation: 24560
It looks like your test classes are not part of the classpath.
<classpath>
<path refid="JUnit 4.libraryclasspath"/>
<pathelement location="${test.build.dir}"/>
</classpath>
Please have a look at this template build.xml
: https://github.com/mplacona/java-junit-template-project/blob/master/build.xml
Upvotes: 1