EMMA问题汇总

1. 没有生成coverage.emma?

这个原因主要是因为在运行代码的时候,没有使用emma instr生成的class来运行,而只是使用javac编译的class来运行。正确的做法是先使用<instr>注入要运行的class,然后把这个class放到运行代码的class path中,如junit

 

2. no sources will be embedded in the report

这个问题曾经困扰了比较长的时间,就是生成的coverage上不能链接到对应的java源文件,后来在emma官方网站找到如下解释:

3.8. Why does <report>/report generate weird warnings like "not all instrumented classes were compiled with source file debug data" or "not all instrumented classes were compiled with line number debug data"?

^

Because you have not compiled all your classes with full debug data, EMMA is "gracefully" degrading to not doing any source linking and not generating any line coverage data.

Depending on your original intentions, you have several options:

  • If you want line coverage and source code linking, recompile and reinstrument with full debug data. If you are compiling in several steps, you might be forgetting the -g (debug='true' in ANT) flag in just one of the steps -- in this case, EMMA's trace ("showing up to 3 classes without full debug info per package...") should help identify which packages were compiled improperly. (Also, see this if the problem persists.)

  • You do want line coverage and source code linking, but a 3rd party lib (not debug-compiled) is messing things up. The right thing to do is to exclude that lib from EMMA's instrumentation in the first place.

  • You are using EMMA on someone else's compiled classes (no sources) or you only want basic block coverage. The right thing to do is to remove the line coverage column from the report and ignore all remaining warnings.

 

简单来说,就是在编译生成class文件时,使用dubeg=”true”即可

posted @ 2010-12-06 16:49  lettoo  阅读(587)  评论(0编辑  收藏  举报