0

I have a Spring-Boot maven repository. I can't alter pom.xml to add jacoco-maven-plugin. But I need a test coverage report for this repository.

So my idea was to execute the following command:

mvn clean verify org.jacoco:jacoco-maven-plugin:prepare-agent org.jacoco:jacoco-maven-plugin:report

But in the logs I see:

[INFO] --- jacoco-maven-plugin:0.8.6:prepare-agent (default-cli) @ backend ---
[INFO] argLine set to -javaagent:C:\\Users\\admin\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.6\\org.jacoco.agent-0.8.6-runtime.jar=destfile=C:\\projects\\my-project\\backend\\target\\jacoco.exec
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.6:report (default-cli) @ backend ---
[INFO] Skipping JaCoCo execution due to missing execution data file.

and no report is generated.

What should I do to add "missing execution data file"? And is it even possible to generate Jacoco report without adding anything to the pom.xml?

htshame
  • 6,599
  • 5
  • 36
  • 56

1 Answers1

2

I figured this thing out. Turns out I needed to change the goal's order a bit.

Instead of: mvn clean verify org.jacoco:jacoco-maven-plugin:prepare-agent org.jacoco:jacoco-maven-plugin:report

  1. Clean.
  2. Verify.
  3. Prepare Jacoco Agent.
  4. Build report.

I need to do:

  1. Clean

  2. Prepare Jacoco Agent

  3. Verify

  4. Build report.

    mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report

htshame
  • 6,599
  • 5
  • 36
  • 56
  • Yeah, makes sense, clean everything, attach the plugin, run tests with the plugin attached and generate the report – Eduardo Jun 15 '22 at 17:34