How to increase test code coverage

For the code coverage to increase , one would need to run the tests with the coverage enabled and then view the report generated locally to see the areas covered by jacoco during its coverage parse, then from these one would see the methods (per class) that needs to be covered from the view of the jacoco agent. If these methods are then tested, the coverage would then increase.

For instance in the client we are able to view the class coverage per method

fig 1: jacoco code coverage per class within 

the above report is the coverage within the org.ei.opensrp.path.activity package

Clicking on the classes it displays takes you to the coverage for that class in terms of all its methods it contains. If you then click on any method, it will display the covered areas/methods in green and the areas/methods it considered not covered in red.

e.g from this example, if we tested the areas marked in red, the coverage by jacoco will increase

fig 2: visual for code coverage showing methods in class

Red means the code block was not covered by the tests, While green means code block is covered

The jacoco code coverage file can be found(after running) in the project file ../../reports/jacoco/html/index.html

Also for issues with code coverage for PowerMocked static entities checkout the gotchas here