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.