Clover + Enum + Else block = red?

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

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
Community showcase
Posted Tuesday in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

228 views 4 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you