I am setting up code coverage for a multi-module Java application. The applicati
ID: 660230 • Letter: I
Question
I am setting up code coverage for a multi-module Java application. The application has integration/functional tests which span across modules. For example, module-service, module-dao and module-api would be exercised by a single functional test.
I have the following requirements:
Report transitive code coverage across all three modules: Tests are present only in module-service, but they exercise code in the other two modules as well. I currently use JaCoCo for code coverage because it can calculate this transitive coverage through its run-time instrumentation feature.
Filter out unwanted functions (not classes) from coverage: A number of compile-time enhancer tools generate synthetic methods and/or code blocks in the compiled code. This skews coverage considerably for smaller classes.
I've tried Cobertura and Emma (which support only[2]) and JaCoCo (which supports only [1]). Is there a good library which supports both of these objectives?
Explanation / Answer
Our (Semantic Designs) Java Test Coverage Tool will do this. It isn't a library; rather it is a set of tools, but I think that is what OP meant anyway.
It operates by instrumenting the source code that you designate (on a class source file by class source file basis). This gives you a lot of control over what gets instrumented. It also means the test coverage data shown is precise down to line and column; if you have several conditionals in a single line, our test coverage tool will track their statuses separately.
Requirement 1: If you instrument the 3 modules all at once, you will get a unified test coverage report across all 3 modules. If you instrument the 3 modules separately, you can collect/display coverage data for each module separately; however, the tool can combine test coverage reporting data from different sets of instrumentation, so you can easily construct the report as if you had instrumented all 3 modules at once.
Requirement 2: Automatically generated class files presumably don't have source code that you instrument. So, no coverage data for those class files is collected.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.