Bil*_*sar 11 code-coverage maven jenkins jacoco
我正进入(状态
由于缺少执行数据文件而跳过JaCoCo执行:/scratch/jenkins/workspace/sonar-test/target/jacoco.exec错误
我的pom档案是:
<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>
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
Pio*_*iec 15
您需要在surefire插件配置中添加$ {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>
Run Code Online (Sandbox Code Playgroud)
如果你想要你可以添加其他参数到surefire插件,如下所示:
<argLine>${argLine} -XX:PermSize=128m -XX:MaxPermSize=512m</argLine>
Run Code Online (Sandbox Code Playgroud)
Kor*_*rri 15
丢失的另一个原因jacoco.exec可能是项目中没有任何单元测试.
编辑:我想知道,为什么我的答案被否决,因为没有人在评论中留下任何理由.我们在包含3个子项目的项目中有相同的错误消息.其中一个是新的,没有任何测试 - 添加一个虚拟单元测试错误消失了.
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18744 次 |
| 最近记录: |