Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Clover + Enum + Else block = red?

caduandrade May 13, 2013

Hi,

I can't have 100% coverage when I use enums.

Ex.:

public enum MyEnum {
  A,B;
}

Test:

if(myenum.equals(MyEnum.A) {

} else if(myenum.equals(MyEnum.B) {

}

this last "else if" always give 1 missed false branch.

1 answer

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 13, 2013

You can use a switch statement. For instance:

switch (en) {
   case A:
      break;
   case B:
      break;
}

will show 100% coverage if called with en==MyEnum.A and en==MyEnum.B.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events