在我们的项目中,我们使用了jacoco-maven-plugin
,在构建过程中,我得到了这个错误:
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.5:check (jacoco-check) on project my-project: Coverage checks have not been met. See log for details.
我知道更好的方法是修复覆盖范围等等。但有时我只是需要快速构建一个项目。是否有用于此目的的某种参数?像mvn clean install -Dskip.jacoco.check=true
或其他快速跳过此检查的方式?
发布于 2020-08-27 16:49:43
正如@wemu在下面评论的那样,OP u可以使用-Djacoco.skip=true
命令行选项暂时跳过Jacoco代码插装和覆盖报告生成。示例:
mvn clean test -Djacoco.skip=true
mvn clean verify -Djacoco.skip=true
mvn clean package -Djacoco.skip=true
mvn clean install -Djacoco.skip=true
发布于 2020-07-24 15:03:45
您可以使用pom.xml或sonar-project.properties跳过某些java文件的代码覆盖率。
例如:使用下面的插件,在标签中给出不需要代码覆盖率的java文件的包
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<excludes>
<exclude>com/sbi/mdcm/v1_0_0/insurancequote/autogen/**</exclude>
<exclude>com/sbi/mdcm/v1_0_0/insurancequote_resources/autogen/**</exclude>
</excludes>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
sonar-project.properties:
sonar.exclusions=**/com/sbi/mdcm/v1_0/insurancepolicy_adapter/osi/model/*.java
https://stackoverflow.com/questions/60163822
复制