Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 521
tor Avatar asked Mar 19 '13 06:03

tor


People also ask

How does EclEmma determine code coverage?

The Eclipse Plug-InEclEmma retrieves code coverage metrics as conveniently as you execute your test suites directly in the IDE . The plugin can be easily installed from its update site at http://update.eclemma.org/ on any Eclipse installation of version 3.5 or above. It is also available from the Eclipse Marketplace.

What is missed branches in JaCoCo?

Missed complexity again is an indication for the number of test cases missing to fully cover a module. Note that as JaCoCo does not consider exception handling as branches try/catch blocks will also not increase complexity.

What is JaCoCo branch coverage?

JaCoCo mainly provides three important metrics: Lines coverage reflects the amount of code that has been exercised based on the number of Java byte code instructions called by the tests. Branches coverage shows the percent of exercised branches in the code, typically related to if/else and switch statements.


1 Answers

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
like image 75
Maroun Avatar answered Oct 12 '22 01:10

Maroun