I am using the Jacoco Junit task and have tried the following:
<echo>DEBUG: $${junit.fork} = "${junit.fork}"</echo>
<jacoco:coverage
destfile="${target.dir}/jacoco.exec"
append="false">
<junit fork="${junit.fork}" includeAntRuntime="true">
<classpath>
<pathelement path="${main.destdir}"/>
<pathelement path="${test.destdir}"/>
</classpath>
<classpath refid="test.classpath"/>
<formatter type="${junit.formatter.type}"/>
<batchtest todir="${junit.batchtest.todir}">
<fileset dir="${test.destdir}" />
</batchtest>
</junit>
</jacoco:coverage>
And got the following:
test:
[echo] DEBUG: ${junit.fork} = "true"
[jacoco:coverage] Enhancing junit with coverage
BUILD FAILED
D:\build.xml:233: Coverage can only be applied on a forked VM
Total time: 6 seconds
D:\>
As you can see, the property ${junit.fork}was set to true, and I used this property in <junit fork="${junit.fork}"/>.
However, instead of using this property, I just set <junit fork="true">it to work fine:
<jacoco:coverage
destfile="${target.dir}/jacoco.exec"
append="false">
<junit fork="true" includeAntRuntime="true">
<classpath>
<pathelement path="${main.destdir}"/>
<pathelement path="${test.destdir}"/>
</classpath>
<classpath refid="test.classpath"/>
<formatter type="${junit.formatter.type}"/>
<batchtest todir="${junit.batchtest.todir}">
<fileset dir="${test.destdir}" />
</batchtest>
</junit>
</jacoco:coverage>
I performed ant -d testto make sure the Java JVM is deployed when I use the property ${junit.fork}.
Why does JaCoCo insist that the JUnit test does not fork out unless I set the parameter forkto a string trueand not to a property equal to true?
source
share