最近家里添丁,好久没更新blog。现在终于又可以有时间继续更新了。
继续上一次的话题:Powermock and sonar jacoco的覆盖率不兼容问题解决 1
在放弃了offline instrument之后,我们就转战普通的dymanic instrument,具体实现分两步介绍,第一步是配置dymanic instrument,之前参考了官方配置:
http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom.xml
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
在使用这个实现的时候遇到了一个搞笑的问题问题,jacoco的report文件内容是0,很是好奇,仔细看了jacoco-maven-plugin的代码之后发现,
@Override
public void executeMojo() {
final String name = getEffectivePropertyName();
final Properties projectProperties = getProject().getProperties();
final String oldValue = projectProperties.getProperty