我得到了
由于缺少执行数据file:/scratch/jenkins/workspace/sonar-test/target/jacoco.exec错误而跳过JaCoCo执行
我的个人资料是:
<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>我遗漏了什么?
发布于 2015-11-19 09:52:30
缺少jacoco.exec的另一个原因可能是项目中没有任何单元测试。
编辑:我想知道,为什么我的答案被否决了,因为没有人在评论中留下任何理由。我们在由3个子项目组成的项目中有相同的错误信息。其中一个是新的,没有任何测试-在添加了一个虚拟单元测试错误之后就消失了。
发布于 2014-08-19 08:05:12
您需要添加${argLine}以确保插件配置。示例:
<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到尽是火插件:
<argLine>${argLine} -XX:PermSize=128m -XX:MaxPermSize=512m</argLine>发布于 2014-08-19 00:26:41
将您的<profile>的<build>改为,注意:使用最新版本的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
复制相似问题