photo by SHELL RS @RSSHELL

Cobertura common glitches and solutions

Cobertura report shows zero or 100% coverage? Here are the points to remember

Shell RS
Computer and Web Technologies
2 min readOct 17, 2013

--

I have spent number of hours to find out whats wrong with my Cobertura code coverage report, why I am not able to see the real results. Specially, if you are capturing the coverage information for Web application.

The point was, I messed up the Cobertura configuration. I am going to highlight few of the points that one should take care to get the real code coverage report using Cobertura:

  1. Your script might not be pointing to any .ser file. In this case, Cobertura itself creates the new .ser file. This is the common mistake programmers do with the .ser file. This data file should be pointed to right location. Same location should be used for instrumentation, test execution and report generation. Note: There is exception, when for different module testing different .ser files could be used and merged later for detailed information.
  2. You might have deleted the existing .ser file, but existing instrumented classes are not being deleted. This leads to mismatch between .ser file and instrumented classes, resultant wrong coverage information
  3. You might have instrumented the classes before compilation of the classes
  4. While executing the test, you might not have placed instrumented classes before the compiled classes in classpath. You should always place the instrumented classes prior to compiled classes in classpath.
  5. If you are using the ANT script then make sure that application/web server should be shutdown before generating the cobertura coverage information.

Let me know if you have other points that helps to get rid out of these configuration related issue while setting up the Cobertura.

Happy Code Coverage ;-)

--

--