首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由于缺少执行数据错误而跳过JaCoCo执行

由于缺少执行数据错误而跳过JaCoCo执行
EN

Stack Overflow用户
提问于 2014-08-18 23:12:49
回答 3查看 29K关注 0票数 14

我得到了

由于缺少执行数据file:/scratch/jenkins/workspace/sonar-test/target/jacoco.exec错误而跳过JaCoCo执行

我的个人资料是:

代码语言:javascript
复制
    <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>

我遗漏了什么?

EN

回答 3

Stack Overflow用户

发布于 2015-11-19 09:52:30

缺少jacoco.exec的另一个原因可能是项目中没有任何单元测试。

编辑:我想知道,为什么我的答案被否决了,因为没有人在评论中留下任何理由。我们在由3个子项目组成的项目中有相同的错误信息。其中一个是新的,没有任何测试-在添加了一个虚拟单元测试错误之后就消失了。

票数 23
EN

Stack Overflow用户

发布于 2014-08-19 08:05:12

您需要添加${argLine}以确保插件配置。示例:

代码语言:javascript
复制
        <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>

如果您想要,您可以添加类似这样的其他params到尽是火插件:

代码语言:javascript
复制
<argLine>${argLine} -XX:PermSize=128m -XX:MaxPermSize=512m</argLine>
票数 22
EN

Stack Overflow用户

发布于 2014-08-19 00:26:41

将您的<profile><build>改为,注意:使用最新版本的jacoco-maven-plugin

代码语言:javascript
复制
 <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>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25373452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档