For Emma, this is what the documentation says:首先,您几乎不可能对成熟的J2EE容器使用即时模式(emmarun).原因在于许多J2EE功能都需要特殊的类加载,这将在EMMA仪器类加载器之外进行.服务器可能运行正常,但是您可能没有覆盖数据.First of all, there is little chance that you will be able to use the on-the-fly mode (emmarun) with a full-blown J2EE container. The reason lies in the fact that many J2EE features require specialized classloading that will happen outside of EMMA instrumenting classloader. The server might run fine, but you will likely get no coverage data.因此,正确的过程是在部署之前对类进行检测(脱机​​模式).脱机检测始终遵循相同的编译/仪器/程序包/部署/获取覆盖率/生成报告顺序.请按照下列步骤操作:Thus, the correct procedure is to instrument your classes prior to deployment (offline mode). Offline instrumentation always follows the same compile/instrument/package/deploy/get coverage/generate reports sequence. Follow these steps: 使用EMMA的instr工具来检测所需的类.可以在包装之前将其作为编译后的步骤进行.但是,许多用户还发现让EMMA直接处理罐子很方便(使用覆盖模式就地就地进行处理,或者以全拷贝模式通过创建所有的单独检测副本); 正常进行J2EE打包,但不要在此级别(即,在.war,.ear等内部)中将emma.jar作为lib包含在内. 找到容器使用的任何JRE,然后将emma.jar复制到其/lib/ext目录中.如果不可能,则将emma.jar添加到服务器类路径(以特定于服务器的方式); 部署您的检测类,.jars,.wars,.ears等,并通过客户端测试用例或以交互方式或以任何方式对J2EE应用程序进行练习/测试; 要获取Coverage转储文件,您有3个选项,其中存在哪些选项可控制EMMA何时转储运行时coverage数据?强烈建议您将v2.1中提供的ctl工具与coverage.get控制命令配合使用. use EMMA's instr tool to instrument the desired classes. This can be done as a post-compilation step, before packaging. However, many users also find it convenient to let EMMA process their jars directly (either in-place, using overwrite mode, or by creating separate instrumented copies of everything, in fullcopy mode); do your J2EE packaging as normal, but do not include emma.jar as a lib at this level, that is, within your .war, .ear, etc; locate whichever JRE is used by the container and copy emma.jar into its /lib/ext directory. If that is impossible, add emma.jar to the server classpath (in a server-specific way); deploy your instrumented classes, .jars, .wars, .ears, etc and exercise/test your J2EE application via your client-side testcases or interactively or whichever way you do it; to get a coverage dump file, you have three options described in What options exist to control when EMMA dumps runtime coverage data?. It is highly recommended that you use coverage.get control command with the ctl tool available in v2.1. 对于三叶草,请查看使用分布式应用程序页面For clover, check the Working with Distributed Applications page. 这篇关于测量远程脚本测试的代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-22 08:46