[英]Manuel Tests Code coverage on Sonarqube
I would like to get code coverage using JaCoCo and display it on Sonarqube after several manual and automated End-to-End tests. 我想使用JaCoCo获得代码覆盖率,并在进行几次手动和自动的端到端测试后将其显示在Sonarqube上。 Currently, we can also collect
JUnit
tests coverage which is triggered during mvn test
目前,我们还可以收集在
mvn test
期间触发的JUnit
测试覆盖率
It looks like I need to instrument the code on JVM using Jacoco Agent . 看来我需要使用Jacoco Agent在JVM上检测代码。 But I need some examples to this.
但是我需要一些例子。 First of all, I need to know where can I get Jacoco agents?
首先,我需要知道在哪里可以找到Jacoco代理商?
When you have maven already up and running, watch it's output. 当您已经启动并运行Maven时,请观看其输出。 Jacoco prepares an argument line for surefire that contains a pointer to the agent:
Jacoco为surefire准备了一个参数行,其中包含指向代理的指针:
[INFO] --- jacoco-maven-plugin:0.7.5.201505241946:prepare-agent (pre-unit-test) @ examples ---
[INFO] jacoco.surefireArgLine set to -javaagent:E:\\mvnrepository\\org\\jacoco\\org.jacoco.agent\\0.7.5.201505241946\\org.jacoco.agent-0.7.5.201505241946-runtime.jar=destfile=E:\\examples\\target\\jacoco-ut.exec,append=true,includes=org.example.*
The generated argline is basically the same as you may use for the JVM you want to generate coverage data for: 生成的argline与您要用于生成以下方面的coverage数据的JVM所使用的基本相同:
-javaagent:E:\\mvnrepository\\org\\jacoco\\org.jacoco.agent\\0.7.5.201505241946\\org.jacoco.agent-0.7.5.201505241946-runtime.jar=destfile=E:\\example\\target\\jacoco-ut.exec,append=true,includes=org.example.*
After you've done with the manual tests you have to re-run sonar analysis to pick up the unit test results. 进行完手动测试后,您必须重新运行声纳分析以获取单元测试结果。 Note that the destfile in the argline must point to a location in your maven structure.
请注意,argline中的destfile必须指向您的maven结构中的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.