Testing the coverage metric of JMockIt

After yesterdays article about Code Coverage terminology I thought more about the code coverage metric JMockIt uses. I created a simple class and a unit test to get more insights:

This is as simple as it gets. The example is taken from the Wikipedia page on Kontrollflussorientierte Testverfahren again. For 100% statement coverage you only need one test case, in which y > x. Then all statements are executed and you have 100% statement coverage.

And here is the resulting JMockit coverage report:

As you can see, JMockit tells us that every single statement is executed, exactly 1 time, with this test case. And that's exactly what I understand as statement coverage and it is in full compliance to the ISTQB terminology. Now, to make my point really clear, let me change the class as follows:

I added the empty ELSE statement that I omitted first. And I run JMockit again to get a new coverage report:

This is not 100% branch coverage, ISTQB certified or not. ;-) My point on this is, if you want to use a tool to verify your testing requirements, make sure that you know what the tool is measuring. And make sure you read the discussion thread in the JMockit users group.

*Update* I created a Cobertura coverage report for CoverMeSimple now:

Weitere Artikel

Crossfit Open WOD 18.4

Crossfit Open WOD 18.3

Crossfit Open WOD 18.2

Crossfit Open WOD 18.1

Match only your own email in Evolution filters

Gronkh ist jetzt ein Rundfunksender...

Crossfit Regionals 2018 in Berlin

Crossfit Open 2018

Qutebrowser userscript for TT-RSS

Aufbau eines Hackintosh