枚举类型的艾玛覆盖 [英] Emma coverage on Enum types

查看:150
本文介绍了枚举类型的艾玛覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行EclEmma,Eclipse的Emma插件,覆盖报告仅显示了我定义的枚举的部分覆盖,即使它显示了枚举中唯一被覆盖的值。我假设隐含的方法有一个覆盖率差距,但是我不太清楚。



例如,使用这个枚举,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屋!

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