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

There is a quite easy workaround - just put each logic predicate on a separate line, like this:

if (x 
    || y) {
    System.out.println("BRANCH: " + x + ", " + y);
    // Do stuff
}

Now when you run the analysis, the marker should point directly to the branch that is missed. After you've added coverage, you can reformat your code the right way.


An open issue on the github repo for Eclemma's parent, jacoco, suggests that such a feature would actually be a bit difficult to include.

However, even without an Eclemma feature, if the goal is just to figure out the branches missed in a specific case, you could instrument your code to keep track. The simplest example is old fashioned print statements:

if (x || y) {
    System.out.println("BRANCH: " + x + ", " + y);
    // Do stuff
}

Then look at the output and see what branches you actually hit (e.g. java ... | grep "BRANCH:" | sort | uniq). (not terribly satisfying, I know.)


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