枚举类型的艾玛覆盖 [英] Emma coverage on Enum types
问题描述
例如,使用这个枚举,EclEmma突出显示绿色的一切,除了包裹声明:
package com.blah;
public enum UserRole {
HAS_ACCESS
}
如果我提到课程的覆盖细节,我看到这样:
我的问题是,使用EclEmma在我的枚举类上获得100%覆盖率的最佳方法是什么?
你看到的是由于枚举而生成的一些隐藏的字节码。
为了摆脱这个问题,添加一个调用enum中的values()和valueOf()方法,如前面提到的Carl Manaster和Peter Lawrey。
I'm running EclEmma, the Emma plugin for Eclipse, and the coverage report shows only partial coverage for an Enum I've defined, even though it shows the only value in the Enum as being covered. I'm assuming that there is a coverage gap for the implied methods that back the Enum, but I'm not quite sure.
For example, with this Enum, EclEmma highlights everything in green, except for the package declaration:
package com.blah;
public enum UserRole {
HAS_ACCESS
}
If I pull up the coverage details for the class, I see this:
My question is, what is the best way to get 100% coverage on my Enum classes using EclEmma?
What you're seeing is some hidden bytecode being generated due to an enumeration.
To get rid of this issue, add a call to the values() and valueOf() methods in the enum, as mentioned earlier by Carl Manaster and Peter Lawrey.
这篇关于枚举类型的艾玛覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!