Jacoco ant task - no jacoco.exec exit

I configured the Ant task as

<target name="test" depends="init"> <jacoco:coverage destfile="target/jacoco.exec"> <junit printsummary="yes" haltonfailure="yes" fork="yes" forkmode="once"> <classpath refid="my_project.path"/> <formatter type="plain"/> <formatter type="xml"/> <batchtest fork="false" todir="target/test-reports"> <fileset dir="test"> <include name="**/*Test.java"/> </fileset> </batchtest> </junit> </jacoco:coverage> </target> 

Which gives the expected junit result. However, target/jacoco.exec never created. I have no errors when performing the ant test report task.

test: [jacoco: coverage] Improving junit with coverage

 ... [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,009 sec 

report: [jacoco: report] Downloading the runtime data file / home / usr / Workspaces / my _project / target / jacoco.exec

BUILD FAILED / home / usr / Workspaces / my_project / build.xml: 73: cannot read the runtime data file / home / usr / Workspaces / my _project / target / jacoco.exec

Total time: 14 seconds

It seems that I'm missing something, I can not understand what exactly.

+7
source share
2 answers

I have found a reason. This is stupid, but there were no protocols indicating an error:

batchtest fork = "true" todir = "target / test-reports"

The fork parameter was set to false in batchtest. Returning to true results in the expected jacoco.exec .

+9
source

Doing the report task alone is not enough. You will need to configure and run the coverage Ant task to include coverage data as a writer in the jacoco.exec file. See here

+1
source

All Articles