问题
I have been looking to generate code coverage from jar build file,with jacoco.
I found this command
java -jar jacococli.jar dump [--address <address>] --destfile <path> [--help] [--port <port>] [--quiet] [--reset] [--retry <count>]
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>
回答1:
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
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 comes with a command line interface to perform basic operations from the command line.
and later also states
For more sophisticated usage especially with larger projects please use our integrations with various build tools.
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
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 report will be in directory
path/for/report
来源:https://stackoverflow.com/questions/55397944/how-to-create-jacoco-code-coverage-from-jacoco-exec-file-that-is-generated-from