I'm trying to integrate codecoverage with jacoco in my junit tests that are launched by an ant task. The fact that jacoco forces me to fork my junit it's given me some problem, since my classpath is quite long and the fork crashes. I'm using manifestclasspath to add my classpath in a jar file an send my new jar as an argument to the VM but it's not working. My tests run but they all return a ClassNotFoundException. Here's a portin of how I've configured my ant process.
<path refid="bin.classpath"/>
bin.classpath contains all the paths that I need to put in my .jar file.
<target name="run-unit-tests" depends="init" description="Runs all the unit tests">
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="jacocoant.jar" />
</taskdef>
<manifestclasspath property="binjar" jarfile="binManifest.jar">
<classpath refid="bin.classpath" />
</manifestclasspath>
<jar destfile="manifestJars/binManifest.jar">
<manifest>
<attribute name="Class-Path" value="${binjar}" />
</manifest>
</jar>
<jacoco:coverage destfile="results/jacoco.exec" xmlns:jacoco="antlib:org.jacoco.ant">
<junit fork="true" reloading="false" showoutput="true">
<classpath>
<pathelement path="${projects.dir}/AntProject/manifestJars/binManifest.jar" />
</classpath>
<batchtest todir="${test.data.dir}" fork="true">
<fileset dir="${projects.dir}/ProjectFolder1/src" />
<fileset dir="${projects.dir}/ProjectFolder2/src" />
</batchtest>
</junit>
</jacoco:coverage>
</target>
If I look at console log when running the ant-task I can see how my new .jar file is being send:
-classpath''C:\Users\XXX\Project\AntProject\manifestJars\binManifest.jar;
If I open the binManifest.jar created I find a MANIFEST.MF file with all my paths inside Class-Path property with the format: ../../Class1/bin ../../Class2/bin ../../ClassN/bin. But for some reason all my tests fail because my classes are not found. What am I missing? Thanks.
../../Class1/bin) wield guess is that maybe working directory is incorrect. - Godin