如何将JaCoCo Agent附加到应用程序服务器 [英] How to attach JaCoCo Agent to application server

查看:111
本文介绍了如何将JaCoCo Agent附加到应用程序服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JBoss并从Jenkins运行Selenium测试.我想测量Selenium测试中的代码覆盖率,因此显然我应该将JaCoCo Java代理附加到服务器.我这样做是这样的:

I am using JBoss and running Selenium tests from Jenkins. I want to measure code coverage from Selenium tests, so apparently I should attach the JaCoCo java agent to the server. I have done like this:

./run.sh -c Default -Djavaagent:[path to Jenkins workspace]/tools/libs/jacocoagent.jar=destfile=[path to Jenkins]/jacoco.exec

但是,从未生成任何输出文件.我在这里指向Jenkins路径中的jacocoagent.jar,但这是否意味着jacocoagent.jar和jacoco.exec必须位于实际的服务器路径中,而不是Jenkins?

However, no output file is ever generated. I am here pointing to jacocoagent.jar in the Jenkins path, but is it so that the jacocoagent.jar and jacoco.exec must be in the actual server path, not Jenkins?

推荐答案

javaagent需要作为VM选项传递,如下所示:

The javaagent needs to be passed as a VM option like this :

-javaagent:[path to Jenkins workspace]/tools/libs/jacocoagent.jar=destfile=[path to Jenkins]/jacoco.exec

您将其作为系统属性传递(使用-D).

You are passing it as a system property (using -D).

您可以通过JAVA_OPTS环境变量将VM选项传递给Jboss应用服务器. (如果在运行run.sh脚本之前导出了JAVA_OPTS,则run.sh将对其进行拾取).这样的事情应该做:

You can pass VM options to the Jboss application server through a JAVA_OPTS environment variable. (the run.sh will pick it up if the JAVA_OPTS is exported before running the run.sh script). Something like this should do :

export JAVA_OPTS="$JAVA_OPTS -javaagent:[path to Jenkins workspace]/tools/libs/jacocoagent.jar=destfile=[path to Jenkins]/jacoco.exec"
./run.sh

有关javaagent配置的更多信息,请参见:

More information on the javaagent configuration can be found here :

http://www.eclemma.org/jacoco/trunk/doc/agent.html

这篇关于如何将JaCoCo Agent附加到应用程序服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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