3
votes

I'm running my webApp using Jetty with my instrumented classes. After the shutdown of Jetty i'm taking the generated .set file and creating a cobertura report using the command line tool.

I always get 100% coverage results on any class. It seems that Cobertura takes into account only the lines that were executed during testing, and doesn't get the full class data.

I've tried to add source files to the reports - no help. I also tried to take the .ser file created after the instrumentation and merge it with .ser file created after Jetty shutdown (it is actually the same file, but before running Jetty I backed-up the .ser which was created after instrumentation) - no help here either.

Can someone please help??

Thanks

2

2 Answers

2
votes

100% coverage is a clear indicator, that the sources are missing for the report. You should check your configuration for creating the report.

Make sure that:

  • you give the right folder
  • the source folder is structured like the packages, and not just all classes in one dir
2
votes

As explained at http://cobertura.sourceforge.net/faq.html, in the answer to the question "When I generate coverage reports, why do they always show 100% coverage everywhere?",

"Cobertura is probably using the wrong .ser file when generating the reports. When you instrument your classes, Cobertura generates a .ser file containing basic information about each class. As your tests run, Cobertura adds additional information to this same data file. If the instrumented classes can not find the data file when running then they will create a new one. It is important that you use the same cobertura.ser file when instrumenting, running, and generating reports."

In my case, I experienced this issue when instrumented classes were in one .ser and during execution I was generating another .ser. Generating the HTML report "just" from the second .ser shown the problem mentioned in the question. Merging the two datafiles (.ser), and regenerating the report, solved the issue.

Refer to http://cobertura.sourceforge.net/commandlinereference.html for "Merging Datafiles" information.