- 浏览: 110550 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
onecan:
分析的很好
大型网站系统架构分析 -
ruanwxh:
为什么我用oracle的例子会出现下面的情况
编绎触发器没错 ...
Oracle触发器介绍 -
lauphai:
不错,拜读了!!!
大型网站系统架构分析 -
shinelgz:
Oracle触发器介绍 -
shinelgz:
Oracle触发器介绍
Introduction
EMMA is an open-source toolkit for measuring and reporting Java code coverage. EMMA distinguishes itself from other tools by going after a unique feature combination: support for large-scale enterprise software development while keeping individual developer's work fast and iterative. Every developer on your team can now get code coverage for free and they can get it fast!
Chances are, you've come here already knowing what coverage is all about and are, in fact, wondering what EMMA offers and why it is worth checking out. Explore the rest of this site to see why.
EMMA features at a glance
- EMMA can instrument classes for coverage either offline (before they are loaded) or on the fly (using an instrumenting application classloader).
- Supported coverage types: class, method, line, basic block. EMMA can detect when a single source code line is covered only partially.
- Coverage stats are aggregated at method, class, package, and "all classes" levels.
- Output report types: plain text, HTML, XML. All report types support drill-down, to a user-controlled detail depth. The HTML report supports source code linking.
- Output reports can highlight items with coverage levels below user-provided thresholds.
- Coverage data obtained in different instrumentation or test runs can be merged together.
- EMMA does not require access to the source code and degrades gracefully with decreasing amount of debug information available in the input classes.
- EMMA can instrument individial .class files or entire .jars (in place, if desired). Efficient coverage subset filtering is possible, too.
- Makefile and ANT build integration are supported on equal footing.
- EMMA is quite fast: the runtime overhead of added instrumentation is small (5-20%) and the bytecode instrumentor itself is very fast (mostly limited by file I/O speed). Memory overhead is a few hundred bytes per Java class.
- EMMA is 100% pure Java, has no external library dependencies, and works in any Java 2 JVM.
Use EMMA in WebLogic
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:
- 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 <jre dir>/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.
Example, Offline Mode with Weblogic
This example tests the PokerHand class via a simple web app, where an HTML file is used to invoke the PokerHand class via a servlet. The build steps are as follows:
- The Ant build compiles the Java source and instruments the classes.
- The instrumented classes and web resources are bundled into a WAR file.
- Tomcat must have access to the Emma jar. One way is to copy emma.jar to the $JAVA_HOME/jre/lib/ext directory, where JAVA_HOME is the JVM used by Tomcat.
- The user deploys the WAR file, starts Tomcat, and tests via the HTML page.
- When Tomcat is shutdown, "coverage.ec" is written to $TOMCAT_HOME/bin.
- The above file is copied to the example directory so that the report can be generated.
Again, the resulting report is similar, where the coverage level is a direct reflection of the number of tests explored via the browser.
This example exercises PokerHand.java via the PokerHandServlet, using Emma to report on the code-coverage.
It uses the Emma's "offline mode" to instrument the Java classes before building a war file. After exercising the servlet, Emma is used to generate a report.
Run Build.xml
this will build ./dist/pokerhand.war, and this step may depend on emma_ant.jar.
<?xml version="1.0"?> <project name="PokerHand" default="build" basedir="."> <property name="classes.dir" value="${basedir}/classes" /> <target name="init"> <target name="compile" depends="init" description="typical Java compile"> <target name="clean" description="cleans directories"> <!-- path element used by EMMA taskdef below: --> <!-- this loads <emma> and <emmajava> custom tasks: --> <target name="emma" description="turns on EMMA's instrumentation/reporting"> <target name="instrument" depends="init, compile" description="instruments the Java classes"> <target name="build" depends="instrument" description="builds the war file">
<property name="coverage.dir" value="${basedir}/coverage" />
<property name="dist.dir" value="${basedir}/dist" />
<property name="instr.dir" value="${basedir}/classes_instr" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="src.dir" value="${basedir}/src" />
<property name="web.dir" value="${basedir}/web" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${instr.dir}" />
<mkdir dir="${coverage.dir}" />
<mkdir dir="${dist.dir}" />
<path id="run.classpath">
<pathelement location="${classes.dir}" />
</path>
</target>
<javac debug="on" srcdir="${src.dir}" destdir="${classes.dir}" classpath="${lib.dir}/junit.jar;${lib.dir}/servlet-api.jar" />
</target>
<delete dir="${classes.dir}" />
<delete dir="${classes_instr.dir}" />
<delete dir="${coverage.dir}" />
<delete dir="${instr.dir}" />
<delete dir="${dist.dir}" />
</target>
<path id="emma.lib">
<pathelement location="${lib.dir}/emma.jar" />
<pathelement location="${lib.dir}/emma_ant.jar" />
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<property name="emma.enabled" value="true" />
<property name="out.instr.dir" value="${basedir}/outinstr" />
<mkdir dir="${out.instr.dir}" />
<property name="emma.filter" value="" />
</target>
<emma enabled="true">
<instr instrpathref="run.classpath" destdir="${instr.dir}" metadatafile="${coverage.dir}/metadata.emma" merge="true">
</instr>
</emma>
</target>
<zip destfile="${dist.dir}/pokerhand.war">
<zipfileset dir="${instr.dir}" prefix="WEB-INF/classes" />
<zipfileset dir="${web.dir}" />
</zip>
</target>
</project>
Copy emma.jar file to $DOMAIN_HOME/lib, and deploy war file into Weblogic.
Run app.
Copy coverage.ec from $DOMAIN_HOME to this directory.
Run run.bat (Windows) or run.sh (Linux).
java -classpath emma.jar emma report -r html -in coverage.ec,coverage/metadata.emma -sourcepath src
Sample report
Sample code
Password: hzwangbing.spaces.live.com
Emma-Test.zip
Download (Namipan) Download (SkyDrive)
发表评论
-
GitHub上最火的74个Android开源项目
2014-03-05 14:28 2168GitHub在中国的火爆程 ... -
代码审查最佳实践 for Java
2012-08-15 11:43 825代码审查可以帮助提高代码质量,避免由于代码习惯而造成的 bug ... -
5个让人激动的Java项目
2012-04-09 14:28 895每个Java/JVM领域的技术专家都应从那些项目中获益, ... -
11款用于优化、分析源代码的Java工具
2011-08-02 17:47 1981Below is a list of some too ... -
细说Java GUI:AWT,SWT,Swing
2010-09-19 01:14 7856Overview概述 Jav ... -
使用JMock模拟接口或类
2010-07-14 16:25 2676使用Jmock时,如果给的类型不是一个接口的时候,会抛出一个异 ... -
浅析VO、DTO、DO、PO的概念、区别和用处
2010-06-09 15:18 1859概念: VO(View Object):视图对象,用于展 ... -
使用Java执行JavaScript
2010-06-09 14:58 825一个简单的例子: public static voi ... -
解析Java对象的equals()和hashCode()的使用
2010-06-02 17:27 816前言 在Java语言中, ... -
Java关键字
2010-05-20 10:40 841访问控制: private 私有的。当前类可见prote ... -
Java5泛型的用法,T.class的获取和为擦拭法站台
2010-03-29 19:36 921Java 5的泛型语法已 ...
相关推荐
Emma内存和Mapfile分析器(Emma) 基于任意链接器映射文件进行静态(即,最坏情况)的内存消耗分析。 它会生成大量的.csv文件,这些文件易于过滤和后期处理。 可选的.html和markdown报告以及整洁的数字可以帮助您...
**Emma应用程序概述** Emma是一款专为用户与Trevor知识导航器进行互动设计的应用程序,其核心特性在于提供了一个更加人性化、用户友好的界面。通过Emma,用户可以更轻松地查询信息、获取解答,以及利用Trevor的知识...
电磁采矿阵列(EMMA) EMMA是一种框架,用于捕获和攻击电子设备发出的电磁辐射的痕迹,以便获得加密密钥或其他敏感数据。 安装 推荐的安装EMMA的方法是通过venv : $ cd < emma> $ python -m venv env $ source ...
Emma支持最新的数据流引擎,例如和作为后端协处理器。产品特点用于可扩展数据分析的DSL通过类型嵌入。 相反,Emma基于报价(类似于 )。 这种方法有两个好处。 首先,它允许在DSL中重用Scala原生的声明性构造。 ...
标题中的"emma:hchdshdjhs"似乎是一种命名方式,但没有明确的IT相关含义。描述中的内容同样没有提供具体的信息。不过,标签指出了"Python",这是一个广泛使用的编程语言,我们的讨论将主要围绕Python展开。 Python...
《Emma:一个强大的Java代码覆盖率工具》 Emma是一款广泛使用的Java代码覆盖率工具,它能够帮助开发者在测试过程中了解代码的覆盖率情况,确保测试的全面性和有效性。标题中的"emma-stable-2.1.5320-lib.zip"是Emma...
emma是一项功能全面的网关服务,旨在作为反向代理,适用于为您的Web应用程序启动实验,蓝/绿部署和金丝雀测试。 emma可以作为前端或后端应用程序的网关服务安装。 emma可以在接收HTTP / HTTPS或WebSockets流量的...
《Emma:明确模型检测管理器介绍》一文详细介绍了EMMA (Explicit Model Checking Manager) 这一工具,该工具是针对模型检测过程中自动化程度不足的问题而设计的。模型检测作为一种自动化的技术,其在实际应用中的...
EMMA,全称为Emma Metrics for Measuring and Managing,是一个广泛使用的开源工具,专门设计用于评估Java应用程序的代码覆盖率。在软件开发过程中,测试是至关重要的一步,而代码覆盖率则是衡量测试质量的重要指标...
标题中的"emma_ant.jar,emma.jar合包"指的是将Emma工具的两个主要组件——`emma.jar`和`emma_ant.jar`合并在一起的压缩文件。Emma是一个广泛使用的Java代码覆盖率工具,它提供了对Java应用程序单元测试的覆盖率分析...
关键的配置是 `schedule` 元素中的 `goal` 参数,它应包含 `-Dmaven.test.skip=true|emma:emma`,这样 Maven 就会在跳过常规测试的同时执行 EMMA 的覆盖率分析。 ```xml <!-- ... --> <!-- ... --> ...
EMMA(Engineering Materials Microstructure Analysis)是一款用于粉末颗粒级配分析的专业软件,它在材料科学、化工、矿业等领域有着广泛的应用。粉末颗粒级配是指粉末中不同粒径颗粒的比例和分布,这一特性对粉末...
### 使用Emma进行Android程序代码覆盖率测试 #### 一、引言 在软件开发过程中,确保代码的质量至关重要。其中,代码覆盖率是一种衡量测试充分性的指标,它可以帮助开发者了解哪些部分的代码已被测试覆盖,哪些部分...
EMMA,全称为Emma Metrics for Java,是一款开源的代码覆盖率工具,专为Java应用程序提供精确的测试覆盖率报告。 EMMA的核心功能在于收集和分析执行单元测试后的代码覆盖数据,包括行覆盖率、分支覆盖率、方法覆盖...
### Java Emma工具详解 #### 一、Emma工具简介 Emma是一款强大的开源代码覆盖率工具,用于度量Java应用程序的代码覆盖率。Emma支持多种测试框架,并且能够很好地与持续集成环境和其他开发工具结合使用。通过Emma,...
Ant、JUnit和Emma是三个关键的工具,它们在软件测试和代码覆盖率分析中扮演着重要角色。Ant是一个流行的Java构建工具,JUnit是Java语言的单元测试框架,而Emma则用于代码覆盖率报告。 Ant是一种基于XML的构建工具,...
标题 "emma-2.0.5312-lib.zip" 提供的信息表明,这是一个与 Emma 相关的软件库的压缩文件,版本号为 2.0.5312。Emma 是一个广泛使用的 Java 软件覆盖率工具,它帮助开发者测量和验证程序测试的有效性,确保代码被...
标题中的“emma统计手工测试或Ui测试覆盖率”指的是Emma,一个开源的Java代码覆盖率工具,它可以帮助开发者衡量单元测试和集成测试对代码的覆盖程度。Emma可以与JUnit、TestNG等测试框架配合使用,提供类、方法、行...