Getting "Skipping JaCoCo execution due to missing execution data file" upon executing JaCoCo

MavenJunitJacoco

Maven Problem Overview


I'm using Maven 3.0.3, JUnit 4.8.1, and Jacoco 0.6.3.201306030806, and I am trying to create test coverage reports.

I have a project with unit tests only, but I can't get reports to run, I'm repeatedly getting the error: Skipping JaCoCo execution due to missing execution data file when I run:

mvn clean install -P test-coverage

Here is how my pom is configured:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.14.1</version>
  <configuration>
    <reuseForks>true</reuseForks>
    <argLine>-Xmx2048m</argLine>
  </configuration>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
  <version>2.14.1</version>
  <configuration>
    <reuseForks>true</reuseForks>
    <argLine>-Xmx4096m -XX:MaxPermSize=512M ${itCoverageAgent}</argLine>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>integration-test</goal>
        <goal>verify</goal>
      </goals>
    </execution>
  </executions>
</plugin>
...
<profile>
  <id>test-coverage</id>
  <build>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.6.3.201306030806</version>
        <configuration>
          <destfile>${basedir}/target/coverage-reports/jacoco-unit.exec</destfile>
          <datafile>${basedir}/target/coverage-reports/jacoco-unit.exec</datafile>
        </configuration>
        <executions>
          <execution>
            <id>prepare-unit-tests</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <!-- prepare agent for measuring integration tests -->
          <execution>
            <id>prepare-integration-tests</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <phase>pre-integration-test</phase>
            <configuration>
              <propertyName>itCoverageAgent</propertyName>
            </configuration>
          </execution>
          <execution>
            <id>jacoco-site</id>
            <phase>verify</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</profile>

All my tests run successfully. Here is some of the output from Maven:

[INFO] --- jacoco-maven-plugin:0.6.2.201302030002:prepare-agent (prepare-unit-tests) @ myproject ---
[INFO] argLine set to -javaagent:/Users/davea/.m2/repository/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002-runtime.jar=destfile=/Users/davea/Dropbox/workspace/myproject/target/jacoco.exec
[INFO] 
    ...
Tests run: 14, Failures: 0, Errors: 0, Skipped: 0

[INFO]
    ...
[INFO] 
[INFO] --- jacoco-maven-plugin:0.6.2.201302030002:prepare-agent (prepare-integration-tests) @ myproject ---
[INFO] itCoverageAgent set to -javaagent:/Users/davea/.m2/repository/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002-runtime.jar=destfile=/Users/davea/Dropbox/workspace/myproject/target/jacoco.exec 
[INFO] 
[INFO] --- maven-failsafe-plugin:2.14.1:integration-test (default) @ myproject ---
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO] 
[INFO] --- maven-failsafe-plugin:2.14.1:verify (default) @ myproject ---
[INFO] Failsafe report directory: /Users/davea/Dropbox/workspace/myproject/target/failsafe-reports
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
[INFO] 
[INFO] --- jacoco-maven-plugin:0.6.2.201302030002:report (jacoco-site) @ myproject ---
[INFO] Skipping JaCoCo execution due to missing execution data file
[INFO] 

Any ideas what configuration I'm missing?

Maven Solutions


Solution 1 - Maven

jacoco-maven-plugin:0.7.10-SNAPSHOT

From jacoco:prepare-agent that says:

> One of the ways to do this in case of maven-surefire-plugin - is to > use syntax for late property evaluation: > > > org.apache.maven.plugins > maven-surefire-plugin > > @{argLine} -your -extra -arguments > >

Note the @{argLine} that's added to -your -extra -arguments.

Thanks Slava Semushin for noticing the change and reporting in the comment.

jacoco-maven-plugin:0.7.2-SNAPSHOT

Following jacoco:prepare-agent that says:

> [org.jacoco:jacoco-maven-plugin:0.7.2-SNAPSHOT:prepare-agent] Prepares a property pointing to the JaCoCo runtime agent that can be > passed as a VM argument to the application under test. Depending on > the project packaging type by default a property with the following > name is set: > > * tycho.testArgLine for packaging type eclipse-test-plugin and > * argLine otherwise. > > Note that these properties must not be overwritten by the > test configuration, otherwise the JaCoCo agent cannot be attached. If > you need custom parameters please append them. For example: > > ${argLine} -your -extra -arguments > > Resulting > coverage information is collected during execution and by default > written to a file when the process terminates.

you should change the following line in maven-surefire-plugin plugin configuration from (note the ${argLine} inside <argLine>):

<argLine>-Xmx2048m</argLine>

to

<argLine>${argLine} -Xmx2048m</argLine>

Make also the necessary changes to the other plugin maven-failsafe-plugin and replace the following (again, notice the ${argLine}):

<argLine>-Xmx4096m -XX:MaxPermSize=512M ${itCoverageAgent}</argLine>

to

<argLine>${argLine} -Xmx4096m -XX:MaxPermSize=512M ${itCoverageAgent}</argLine>

Solution 2 - Maven

I faced a bit of a different issue that returned the same error.

Skipping JaCoCo execution due to missing execution data /target/jacoco.exec

The truth is, this error is returned for many, many reasons. We experimented with the different solutions on Stack Overflow, but found this resource to be best. It tears down the many different potential reasons why Jacoco could be returning the same error.

For us, the solution was to add a prepare-agent to the configuration.

<execution>
   <id>default-prepare-agent</id>
   <goals>
       <goal>prepare-agent</goal>
   </goals>
</execution>

I would imagine most users will be experiencing it for different reasons, so take a look at the aforementioned resource!

Solution 3 - Maven

One can also get "Skipping JaCoCo execution due to missing execution data file" error due to missing tests in project. For example when you fire up new project and have no *Test.java files at all.

Solution 4 - Maven

There might a case where some other argline setup or plugin in pom may be overriding jacoco execution order setup.

argLine set to -javaagent:/Users/davea/.m2/repository/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002-runtime.jar=destfile=/Users/davea/Dropbox/workspace/myproject/target/jacoco.exec

One of the example

           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <forkCount>5</forkCount>
                    <reuseForks>true</reuseForks>
                    <argLine>-Dnet.sf.ehcache.disabled=true</argLine>
                </configuration>
            </plugin>

After getting rid of argLine from these plugins, jacoco started to work normally.

Solution 5 - Maven

I know this question is pretty old but if someone like me comes here looking for an answer then this might help. I have been able to overcome the above error with this.

  1. Remove the below piece of code from the plugin maven-surefire-plugin

    true -Xmx2048m

  2. Add the below goal:

    default-prepare-agent prepare-agent

Solution 6 - Maven

FWhat tdrury said:

change your plugin configuration into this:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.6.3.201306030806</version>
    <executions>
      <!-- prepare agent for measuring integration tests -->
      <execution>
        <id>prepare-integration-tests</id>
        <phase>pre-integration-test</phase>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
        <configuration>
          <destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
        </configuration>
      </execution>
      <execution>
        <id>jacoco-site</id>
        <phase>post-integration-test</phase>
        <goals>
          <goal>report</goal>
        </goals>
        <configuration>
          <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
        </configuration>
      </execution>
    </executions>
  </plugin>

Edit: Just noticed one important thing, destFile and dataFile seems case sensitive so it's supposed to be destFile, not destfile.

Solution 7 - Maven

I've tried all answers but only the following combination of advice has worked for me. Why? I had very specific requirements:

  1. JaCoCo generates report when build is run from command line: mvn clean verify (Maven 3.6.0)
  2. Intellij IDEA (2019.01) runs my tests as well
  3. It all works in presence of another javaagent defined in surefire plugin

Solution - prepend argLine value in surefire configuration with "late replacement" maven property @{...} as explained in surefire FAQ (my fixed configuration)

> How do I use properties set by other plugins in argLine? > Maven does property replacement for

> ${...} > values in pom.xml before any plugin is run. So Surefire would never see the place-holders in its argLine property. > Since the Version 2.17 using an alternate syntax for these properties,

> @{...} > allows late replacement of properties when the plugin is executed, so properties that have been modified by other plugins will be picked up correctly.

Failed first try - define jaCoCoArgLine property in prepare-agent goal configuration of jacoco - the scenario failed my second requirement, IntelliJ IDEA couldn't figure out agent for jmockit I use in the project for static method mocking

Solution 8 - Maven

Came accross the same problem just now.

I have a class named HelloWorld, and I created a test class for it named HelloWorldTests, then I got the output Skipping JaCoCo execution due to missing execution data file.

I then tried to change my pom.xml to make it work, but the attempt failed.

Finally, I simply rename HelloWorldTests to HelloWorldTest, and it worked!

So I guess that, by default, jacoco only recognizes test class named like XxxTest, which indicates that it's the test class for Xxx. So simply rename your test classes to this format should work!

Solution 9 - Maven

> When using the maven-surefire-plugin or maven-failsafe-plugin you must not use a forkCount of 0 or set the forkMode to never as this would prevent the execution of the tests with the javaagent set and no coverage would be recorded.

ref: https://www.eclemma.org/jacoco/trunk/doc/maven.html

this is my gist

Solution 10 - Maven

I struggled for days. I tried all the different configurations suggested in this thread. None of them works. Finally, I find only the important configuration is the prepare-agent goal. But you have to put it in the right phase. I saw so many examples put it in the "pre-integration-test", that's a misleading, as it will only be executed after unit test. So the unit test won't be instrumented.

The right config should just use the default phase, (don't specify the phase explicitly). And usually, you don't need to mass around maven-surefire-plugin.

  <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.4</version>
    <executions>
      <execution>
        <id>default-prepare-agent</id>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
      </execution>
      <execution>
        <id>jacoco-site</id>
        <phase>post-integration-test</phase>
        <goals>
          <goal>report</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

Solution 11 - Maven

I was having the same issue. I updated the Jacoco version from 0.6 to 0.8 and updated surefire plugin as well. The following command generated Jacoco reports in site/jacoco/ folder:

mvn clean jacoco:prepare-agent install jacoco:report

My maven configurations are as follows:

<plugins>
	<plugin>
		<groupId>org.jacoco</groupId>
		<artifactId>jacoco-maven-plugin</artifactId>
		<version>0.8.6</version>
		<executions>
			<execution>
				<goals>
					<goal>prepare-agent</goal>
				</goals>
			</execution>
			<execution>
				<id>jacoco-report</id>
				<phase>test</phase>
				<goals>
					<goal>report</goal>
				</goals>
					</execution>
			<execution>
				<id>jacoco-check</id>
				<goals>
					<goal>check</goal>
				</goals>
				<configuration>
					<rules>
						<rule>
							<element>PACKAGE</element>
							<limits>
								<limit>
									<counter>LINE</counter>
									<value>COVEREDRATIO</value>
									<minimum>0.0</minimum>
								</limit>
							</limits>
						</rule>
					</rules>
				</configuration>
			</execution>
		</executions>
	</plugin>
	<plugin>
		<groupId>org.apache.maven.plugins</groupId>
		<artifactId>maven-surefire-plugin</artifactId>
		<version>3.0.0-M5</version>
		<configuration>
			<forkedProcessExitTimeoutInSeconds>60</forkedProcessExitTimeoutInSeconds>
			<forkCount>1</forkCount>
		</configuration>
	</plugin>
</plugins>

Solution 12 - Maven

Try to use:

mvn jacoco:report -debug

to see the details about your reporting process.

I configured my jacoco like this:

<configuration>
    <dataFile>~/jacoco.exec</dataFile>
    <outputDirectory>~/jacoco</outputDirectory>
</configuration>

Then mvn jacoco:report -debug shows it using the default configuration, which means jacoco.exec is not in ~/jacoco.exec. The error says missing execution data file.

So just use the default configuration:

<execution>
	<id>default-report</id>
	<goals>
	</goals>
	<configuration>
		<dataFile>${project.build.directory}/jacoco.exec</dataFile>
		<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
	</configuration>
</execution>

And everything works fine.

Solution 13 - Maven

It happens if the path of your project has blank spaces anywhere, such as:

/home/user/my projects/awesome project

the report is not generated. If that is the case, remove those spaces from directory names, such as:

/home/user/my-projects/awesome-project

or move the project to a directory that doesn't have spaces along the way.

About the plugin configuration, I just needed the basic as below:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.5</version>
    <executions>
        <execution>
            <id>jacoco-initialize</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <execution>
            <id>jacoco-report</id>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>       
</plugin>

Solution 14 - Maven

I have added a Maven/Java project with 1 Domain class with the following features:

  • Unit or Integration testing with the plugins Surefire and Failsafe.
  • Findbugs.
  • Test coverage via Jacoco.

Where are the Jacoco results? After testing and running 'mvn clean', you can find the results in 'target/site/jacoco/index.html'. Open this file in the browser.

Enjoy!

I tried to keep the project as simple as possible. The project puts many suggestions from these posts together in an example project. Thank you, contributors!

Solution 15 - Maven

I know this is late, but just for anyone else who has this issue and nothing seems to fix it (like I had). Make sure that in you pom, your configuration for jacoco inside plugins is not in turn inside pluginManagement. It seems some sort of default for maven is to put the plugins inside pluginManagement. This is almost unnoticeable until you try to add detailed configurations like for jacoco. In order to add these, you need to add them outside of the pluginManagement, otherwise they are effectively ignored. See my poms below for details.

My old pom (that gave the "Skipping jacoco ..." message):

<project>
  ...
  <build>
    <pluginManagement>
      <plugins>
        ...
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.2</version>
          <executions>
            <execution>
              <id>default-prepare-agent</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
            </execution>
            <execution>
              <id>default-report</id>
              <phase>test</phase>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

My new pom (that now compiles a working jacoco report):

<project>
  ...
  <build>
    <pluginManagement>
      <plugins>
        ...
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <executions>
            <execution>
              <id>default-prepare-agent</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
            </execution>
            <execution>
              <id>default-report</id>
              <phase>test</phase>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
          </executions>
      </plugin>
    </plugins>
  </build>
</project>

Solution 16 - Maven

The execution says it's putting the jacoco data in /Users/davea/Dropbox/workspace/myproject/target/jacoco.exec but your maven configuration is looking for the data in ${basedir}/target/coverage-reports/jacoco-unit.exec.

Solution 17 - Maven

My response is very late but for others users In your case you have to configure failsafe pluging to use the command line agent configuration saved in itCoverageAgent variable. For exemple

<configuration>
    <argLine>${itCoverageAgent}</argLine>
</configuration>

In your maven configuration, jacoco prepare the command line arguments in prepare-agent phase, but failsafe plugin doesn't use it so there is no execution data file.

Solution 18 - Maven

Sometimes the execution runs first time, and when we do maven clean install it doesn't generate after that. The issue was using true for skipMain and skip properties under maven-compiler-plugin of the main pom File. Remove them if they were introduced as a part of any issue or suggestion.

Solution 19 - Maven

In my case, the prepare agent had a different destFile in configuration, but accordingly the report had to be configured with a dataFile, but this configuration was missing. Once the dataFile was added, it started working fine.

Solution 20 - Maven

I faced similar error because tests execution were skipped.

I ran my build with similar system parameter : -Dmaven.test.skip.exec=true

Turning this system parameter to false solved the issue.

Solution 21 - Maven

Jacoco Execution data file is a jacoco.exec file which is generated when prepare agent goal is running. When It isn't generated or the correct path isn't set in configuration, you will get that error message. Because Jacoco use It to build test coverage. This usually occur when you use jacoco maven plugin and surfire or failsafe. To ensure that the jacoco.exec file is generated, you have to add argline in you pom.xml file, not in the surfire configuration but inside a properties tag in you pom.xml file.

<properties>
    <argLine>-Xmx2048m</argLine>
</properties>
         

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDaveView Question on Stackoverflow
Solution 1 - MavenJacek LaskowskiView Answer on Stackoverflow
Solution 2 - MavenChad Van De HeyView Answer on Stackoverflow
Solution 3 - MavenTanya JivvcaView Answer on Stackoverflow
Solution 4 - MavenAtish NarlawarView Answer on Stackoverflow
Solution 5 - MavenAlways a newComerView Answer on Stackoverflow
Solution 6 - MavenBoneGoatView Answer on Stackoverflow
Solution 7 - MavenPawel KruszewskiView Answer on Stackoverflow
Solution 8 - MavenafkbrbView Answer on Stackoverflow
Solution 9 - MavenkyakyaView Answer on Stackoverflow
Solution 10 - MavenJianwu ChenView Answer on Stackoverflow
Solution 11 - MavenWaqar DethoView Answer on Stackoverflow
Solution 12 - MavenxiaoLiuLiuView Answer on Stackoverflow
Solution 13 - MavenManoel CamposView Answer on Stackoverflow
Solution 14 - Maventm1701View Answer on Stackoverflow
Solution 15 - MavenDylan CallaghanView Answer on Stackoverflow
Solution 16 - MaventdruryView Answer on Stackoverflow
Solution 17 - MavenjplView Answer on Stackoverflow
Solution 18 - MavenSrini MView Answer on Stackoverflow
Solution 19 - MavenPavan KumarView Answer on Stackoverflow
Solution 20 - MavenStephanView Answer on Stackoverflow
Solution 21 - MavenKenanyView Answer on Stackoverflow