Powermock and sonar jacoco的覆盖率不兼容问题解决 2

本文介绍了在放弃offline instrument后,转向使用dynamic instrument解决Powermock和Sonar Jacoco覆盖率不兼容的问题。通过分析jacoco-maven-plugin的代码,发现需要手动在JVM上设置参数。首先,利用jacoco-maven-plugin生成UT和IT的参数,然后在UT和IT测试阶段分别使用这些参数(surefireArgLine和failsafeArgLine)。最后,文章预告将分享使用Powermockito的agent方法处理覆盖率兼容性问题。
摘要由CSDN通过智能技术生成

最近家里添丁,好久没更新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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值