jacoco 离线模式配置jvm 参数
来源:互联网 发布:淘宝幸运抽奖 编辑:程序博客网 时间:2024/06/08 13:55
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
在使用这个实现的时候遇到了一个搞笑的问题问题,jacoco的report文件内容是0,很是好奇,仔细看了jacoco-maven-plugin的代码之后发现,
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
这个plugin只是帮忙生成jacoco agent参数。然后把参数赋值到指定的变量或者默认变量argLine。具体如何使用在JVM上还需要自己额外设置,具体做法如下:
首先使用jacoco maven plugin 添加prepare-agent属性,且声明一个变量让后面surfire配置参数调用。
然后分别在ut和it使用设置的参数(surefireArgLine和failsafeArgLine)。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
解决了jacoco的问题之后,下一篇介绍powermockito的agent方式解决覆盖率不兼容问题。
如果不使用maven-failsafe-plugin插件,那么:
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> <executions> <!-- Prepares the property pointing to the JaCoCo runtime agent which is passed as VM argument when Maven the surefire plugin is executed. --> <execution> <id>pre-unit-test</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <!-- Sets the path to the file which contains the execution data. --> <destFile>${sonar.jacoco.reportPath}</destFile> <!-- Sets the name of the property containing the settings for JaCoCo runtime agent. --> <propertyName>surefireArgLine</propertyName> </configuration> </execution> <!-- Ensures that the code coverage report for unit tests after unit tests have been run. --> <execution> <id>post-unit-test</id> <phase>test</phase> <goals> <goal>report</goal> </goals> <configuration> <!-- Sets the path to the file which contains the execution data. --> <dataFile>${sonar.jacoco.reportPath}</dataFile> <!-- Sets the output directory for the code coverage report. --><outputDirectory>target/site/jacoco</outputDirectory> </configuration></execution></executions></plugin>
阅读全文
0 0
- jacoco 离线模式配置jvm 参数
- jvm 常用JVM配置参数
- JVM参数配置
- JVM参数配置
- tomcat 配置jvm参数
- JVM参数配置大全
- JVM参数配置详解
- JVM参数配置大全
- Tomcat JVM 参数配置
- JVM参数配置解析
- 详解JVM参数配置
- JVM参数配置
- myeclipse JVM参数配置
- JVM参数配置大全
- JVM配置参数列表
- JVM参数配置
- JVM运行参数配置
- JVM 参数配置
- JSON
- 文章标题
- JS正则表达式(常见验证)
- 数据库范式
- 严蔚敏版数据结构课本代码——算法2.7
- jacoco 离线模式配置jvm 参数
- 图片懒加载处理
- 使用maven管理jar包
- flask+bootstrap实现dashboard中的统计图表
- 【UVa1617】Laptop 笔记本(贪心)
- BigDecimal解决商业运算中丢失精度的问题
- 有关notifyItemRemoved(position)方法导致界面position错乱的解决办法
- 学习教程
- OS模块