Eclemma says 1 of 4 branches not covered, but which branch is it?

tor picture tor · Mar 19, 2013 · Viewed 39.8k times · Source

Is there a simple way to tell which branch I am missing? I.e. I have some code like this:

if (x || y) {
    // do stuff
}

In the coverage highlighting there is a yellow dot in Eclipse that says:

1 of 4 branches missed

but I would like to know which branch is missing.

Answer

Maroun picture Maroun · Mar 19, 2013

What can x and y be?

  • true || true is true (Not covered because of JVM optimization: if the first condition is true, the second won't be evaluated due to short circuit evaluation)
  • false || true is true
  • true || false is true
  • false || false is false