It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Marek Parfianowicz Atlassian Team 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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Opsgenie

Handling Opsgenie Alerts

Hi everyone, welcome to the kb articles for Opsgenie FAQs. I'm one of the Technical Support Engineers for Opsgenie who will be providing weekly posts on FAQs from customers.   All alerts are ...

72 views 0 3
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you