SonarQube的测试覆盖和测试执行

您所在的位置:网站首页 sonar单元测试未覆盖 SonarQube的测试覆盖和测试执行

SonarQube的测试覆盖和测试执行

2023-07-02 08:52| 来源: 网络整理| 查看: 265

sonarqube coverage/

8.4版本包括两个概念:

Test Coverage 测试覆盖 ——测试结果有多少覆盖率 Test Execution 测试执行 ——具体包含多少个测试用例

低版本上,如7.6似乎没有“测试执行”的说法,从7.7版本有对应的文档:https://docs.sonarqube.org/7.7/analysis/coverage/后续的7.8, 7.9直到最新的8.4版本。

mvn test默认绑定的goal是surefire:test,用来执行单元测试——run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed.

所以默认的 mvn test只会生成Test Execution的结果;

添加了jacoco插件并与test阶段绑定后—— mvn test会同时产生(surefire插件生成)单测结果,和(jacoco插件生成)单测覆盖率结果。

此时再执行sonar:sonar后,单测结果就展示为 “Test Execution 测试执行”;单测覆盖率展示为“Test Coverage 测试覆盖”

完成的生命周期可以参考官方说明lifecycle reference

最常用的打包jar阶段对应的plugin和goal如下表——

Phase plugin:goal process-resources resources:resources compile compiler:compile process-test-resources resources:testResources test-compile compiler:testCompile test surefire:test package jar:jar install install:install deploy deploy:deploy

对应的具体plugin信息为具体plugin信息 ——

org.apache.maven.plugins:maven-resources-plugin:2.6:resources org.apache.maven.plugins:maven-compiler-plugin:3.1:compile org.apache.maven.plugins:maven-resources-plugin:2.6:testResources org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test org.apache.maven.plugins:maven-jar-plugin:2.4:jar org.apache.maven.plugins:maven-install-plugin:2.4:install org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy

从上述信息也可以看出来plugin的命名规范和使用中的快捷方式。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3