如何从从JAR文件生成的jacoco.exec文件创建Jacoco代码覆盖率? [英] How to create Jacoco code coverage from jacoco.exec file that is generated from JAR file?
问题描述
我一直在寻找使用jacoco从jar构建文件生成代码覆盖率的方法.
I have been looking to generate code coverage from jar build file,with jacoco.
我找到了此命令
java -jar jacococli.jar dump [--address <address>] --destfile <path> [--help] [--port <port>] [--quiet] [--reset] [--retry <count>]
使其工作,但不知道如何生成jacococli.jar.我通常将其添加为依赖项,但没有任何反应.
to make it work but have no idea how to generate jacococli.jar . I normally added as dependecy but nothing happened.
<dependencies>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.cli</artifactId>
<version>0.8.3</version>
</dependency>
</dependencies>
推荐答案
我找到了这个命令
I found this command
java -jar jacococli.jar dump [--address <address>] --destfile <path> [--help] [--port <port>] [--quiet] [--reset] [--retry <count>]
...被添加为依赖,但没有任何反应
... added as dependecy but nothing happened
jacococli.jar
不能用作依赖项-JaCoCo文档第 https://www.jacoco.org/jacoco/trunk/doc/cli.html
哪个状态
jacococli.jar
is not intended to be used as a dependency - command is shown in JaCoCo documentation on page https://www.jacoco.org/jacoco/trunk/doc/cli.html
which states
JaCoCo带有命令行界面,可从命令行执行.
,后来也声明了
对于更复杂的用法(尤其是在较大的项目中),请使用我们的 集成和各种构建工具.
For more sophisticated usage especially with larger projects please use our integrations with various build tools.
在集成中,有jacoco-maven-plugin
个用于使用Maven生成报告的文档,此插件的文档位于第 https://www.jacoco.org/jacoco/trunk/doc/maven.html
among integrations there is jacoco-maven-plugin
for generation of report using Maven, documentation of this plugin available on page https://www.jacoco.org/jacoco/trunk/doc/maven.html
要使用jacococli.jar
从jacoco.exec
文件生成报告,以用于your.jar
文件
To use jacococli.jar
for generation of report from jacoco.exec
file for your.jar
file
- download
zip
distribution of JaCoCo from https://www.jacoco.org/jacoco/ - extract it for example into directory
jacoco
,jacococli.jar
will be injacoco/lib/jacococli.jar
- open command line in this directory and execute
java -jar lib/jacococli.jar report path/to/jacoco.exec --classfiles path/to/your.jar --html path/for/report
- HTML报告将位于目录
path/for/report
中
这篇关于如何从从JAR文件生成的jacoco.exec文件创建Jacoco代码覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!