如何从从JAR文件生成的jacoco.exec文件创建Jacoco代码覆盖率? [英] How to create Jacoco code coverage from jacoco.exec file that is generated from JAR file?

查看:542
本文介绍了如何从从JAR文件生成的jacoco.exec文件创建Jacoco代码覆盖率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找使用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.jarjacoco.exec文件生成报告,以用于your.jar文件

To use jacococli.jar for generation of report from jacoco.exec file for your.jar file

    > https://www.jacoco.org/jacoco/
  1. 下载JaCoCo的zip发行版. a>
  2. 例如将其提取到目录jacoco中,jacococli.jar将位于jacoco/lib/jacococli.jar
  3. 在此目录中打开命令行并执行
  1. download zip distribution of JaCoCo from https://www.jacoco.org/jacoco/
  2. extract it for example into directory jacoco, jacococli.jar will be in jacoco/lib/jacococli.jar
  3. 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

  1. HTML报告将位于目录path/for/report

这篇关于如何从从JAR文件生成的jacoco.exec文件创建Jacoco代码覆盖率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆