The screenshot below shows a generated HTML report in a browser.
The screen shot shows the report for the Money.java
source file with the green and red bar at the top showing the amount of code coverage on this class. The method, statement and conditional coverage percentages are beside this.
The left-most column shows line numbers. The second column shows the number of times a particular line has been executed during the test run. As you can see, lines 15-17 have been run 156 times by the JUnit tests, whereas line 28 has only been run twice.
If a line is never executed or has only been partially executed, the entire line of code will be highlighted in red. Depending on your browser, you can hover the mouse over a line to get a popup describing in detail the coverage information for that line. The following screenshot shows the coverage on a section of the MoneyBag.java
source file:
Although line 52 of the above MoneyBag
class has been executed 14 times, the method isZero()
has never evaluated to true
so it has not been fully tested. Therefore it, and the following two lines, are highlighted. This is also the case with lines 58 and 59.
This highlighting feature makes it easy for you to see which parts of the code have not been fully exercised by your tests so that you can then improve testing to provide better code coverage.
If any of the lines shaded red contained a bug, they may never be detected because the tests as they are don't test those parts of the code.
If you click on a [+] button on the left side of the class name, table will expand and show methods declared in it. If the HTML report was generated with showLambdaFunctions=true and showInnerFunctions=true options, the table will also show lambda functions declared inside methods or assigned to a class field.
Screen shot: sample report for code containing lambda functions
Naming convention for lambda functions is as follows: <lambda_prefix><parameter_list><sequence_number> where:
For example: $lam_x_y_z#6 means a sixth lambda in the source file having the (x, y, z) => signature.