在运行时转储执行数据 [英] Dump execution data at run time

查看:177
本文介绍了在运行时转储执行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JaCoCo生成代码覆盖率报告,并且我有多种方案可以为其生成单独的报告。问题在于该程序非常庞大,大约需要2分钟才能启动并加载所有类文件。

I'm using JaCoCo to generate code coverage report and I have a number of scenarios to generate separate reports for. The problem is that the program is extremely huge and takes around 2 minuted to start and load all the class files.

我想在其中一个方案完成后立即在运行时获取执行数据,然后从下一个方案开始,而不是针对每个方案重新启动服务器。

I want to fetch the execution data on run time as soon as one of those scenarios is completed and then start with the next scenario, instead of restarting the server for each scenario.

有办法吗?

推荐答案

全部以下摘录自JaCoCo官方文档,网址为 http://www.jacoco.org/jacoco/trunk / doc /

All below is taken from official JaCoCo documentation at http://www.jacoco.org/jacoco/trunk/doc/

http://www.jacoco.org/jacoco/trunk/doc/agent.html 具有选项 output



  • 文件:在VM终止时,执行数据被写入destfile属性中指定的文件中。

  • tcpserver :代理在地址和端口属性指定的TCP端口上侦听传入连接。执行数据是
    写入此TCP连接。

  • tcpclient :在启动时,代理将连接到由address和port属性指定的TCP端口。执行数据是
    写入此TCP连接。

  • file: At VM termination execution data is written to the file specified in the destfile attribute.
  • tcpserver: The agent listens for incoming connections on the TCP port specified by the address and port attribute. Execution data is written to this TCP connection.
  • tcpclient: At startup the agent connects to the TCP port specified by the address and port attribute. Execution data is written to this TCP connection.

和选项 jmx


如果设置为true,代理将公开功能通过JMX

通过JavaDoc中描述的JMX功能公开,其中提供了以下三种方法:

exposed via JMX functionality as described in JavaDoc among others provides three following methods:


byte [] getExecutionData(布尔值重置)
返回当前执行数据。

byte[] getExecutionData(boolean reset) Returns current execution data.

void dump(boolean reset)
通过配置的输出触发当前执行数据的转储。

void dump(boolean reset) Triggers a dump of the current execution data through the configured output.

void reset()
重置所有险种信息。

void reset() Resets all coverage information.

同样从文档中也可以找到蚂蚁任务转储-
http://www.jacoco.org/jacoco/trunk/doc/ant.html

Again from documentation there is also Ant Task dump - http://www.jacoco.org/jacoco/trunk/doc/ant.html:

此任务允许从另一个JVM远程收集执行数据,而无需停止它。
远程转储对于长时间运行的Java进程(如应用程序服务器)很有用。

This task allows to remotely collect execution data from another JVM without stopping it. Remote dumps are usefull for long running Java processes like application servers.

转储命令-
http:// www.jacoco.org/jacoco/trunk/doc/cli.html

转储目标 jacoco-maven-plugin - http://www.jacoco.org/jacoco/trunk/doc/dump-mojo.html

API使用示例包括:



  • MBeanClient.java此示例连接到coverage代理以通过JMX收集
    执行数据。

  • ExecutionDataClient.java示例
    连接到coverage代理以通过远程
    协议收集执行数据。

  • ExecutionDataServer.java此示例启动套接字服务器
    来通过远程协议从代理收集执行数据。

这篇关于在运行时转储执行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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