Skipping JaCoCo execution due to missing execution data error

↘锁芯ラ 提交于 2020-06-11 17:02:29

问题


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?


回答1:


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>



回答2:


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.




回答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>


来源:https://stackoverflow.com/questions/25373452/skipping-jacoco-execution-due-to-missing-execution-data-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!