14

I am getting

Skipping JaCoCo execution due to missing execution data file:/scratch/jenkins/workspace/sonar-test/target/jacoco.exec error

My pom profile is:

    <profile>
        <id>test-coverage</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.plugin.version}</version>
                    <configuration combine.self="override">
                        <redirectTestOutputToFile>true</redirectTestOutputToFile>
                        <testFailureIgnore>true</testFailureIgnore>
                           <groups>com.project.test.annotation.QuickTest</groups>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.7.1.201405082137</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>report</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </build>
    </profile>

What am I missing?

eebbesen
  • 5,070
  • 8
  • 48
  • 70
Bilal Yasar
  • 947
  • 2
  • 11
  • 24
  • 2
    possible duplicate of [Getting "Skipping JaCoCo execution due to missing execution data file" upon executing JaCoCo?](http://stackoverflow.com/questions/18107375/getting-skipping-jacoco-execution-due-to-missing-execution-data-file-upon-exec) – assylias Jun 11 '15 at 18:12

3 Answers3

23

You need to add ${argLine} to surefire plugin configuration. Example:

        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.7.1.201405082137</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>report</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.14.1</version>
                    <configuration>
                        <argLine>${argLine}</argLine>
                    </configuration>
                </plugin>
            </plugins>
        </build>

If you want you can add other params to the surefire plugin like that:

<argLine>${argLine} -XX:PermSize=128m -XX:MaxPermSize=512m</argLine>
Piotr Chowaniec
  • 1,160
  • 12
  • 25
  • 1
    Sure, but why? What does the argline do for surefire? – jbruni Jan 03 '18 at 23:53
  • Thanks a lot Piotr, this makes a lot of sense, and after reading a lot of very strange answers (a way to say it) related to this issue, some clearness is really welcome. – tonio Jun 01 '20 at 23:07
23

Another reason for missing jacoco.exec can be that there aren't any unit tests in project.

Edit: I would like to know, why my answer was voted down since nobody left any reason in comments. We had the same error message in project consisting of 3 sub-projects. One of them was new and without any tests - after adding one dummy unit test error was gone.

Jens
  • 67,715
  • 15
  • 98
  • 113
Korri
  • 571
  • 3
  • 10
  • 5
    To whomever gave the downvote. This is one of the reasons why the `Skipping JaCoCo execution due to missing execution data ` comes up. I had the same issue till i added a sample test class and it worked. – Vishnu667 Apr 17 '16 at 22:23
  • 2
    you are a savior! – newbie Aug 26 '16 at 14:11
3

change your <profile>'s <build> to, note: use latest version for jacoco-maven-plugin

 <build>
        <plugins>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.6.3.201306030806</version>
            <executions>
              <!-- pre-unit-test execution helps setting up some maven property,
                which will be used later by JaCoCo -->
              <execution>
                <id>pre-unit-test</id>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
                <configuration>
                  <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                  <!-- passing property which will contains settings for JaCoCo agent.
                    If not specified, then "argLine" would be used for "jar" packaging -->
                  <propertyName>surefireArgLine</propertyName>
                </configuration>
              </execution>
              <!-- report phase setup -->
              <execution>
                <id>post-unit-test</id>
                <phase>test</phase>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <!-- output file with report data. -->
                  <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                  <!-- output directory for the reports. -->
                  <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14</version>
            <executions>
              <execution>
                <id>default-test</id>
                <phase>test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <argLine>${surefireArgLine}</argLine>
                </configuration>
              </execution>
            </executions>
            <configuration>
              <argLine>-XX:MaxPermSize=512m</argLine>
            </configuration>
          </plugin>
        </plugins>
  </build>
jmj
  • 237,923
  • 42
  • 401
  • 438