Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get Emma or Cobertura, with Maven, to report coverage on source code in other modules?
    text
    copied!<p>I have a multi-module Maven setup with Java code.</p> <p>My unit tests, in one of the modules, exercise code in multiple modules. Naturally, the modules have inter-dependencies, and code in all relevant modules is compiled as needed in advance of test execution.</p> <p>So: How can I get a report on the coverage of the entire codebase?</p> <hr> <p>Note: I am not asking how to combine the results of coverage for tests in multiple modules. I am asking how to get coverage for tests in a single module using instrumented code from multiple modules. Anyone interested in the former might refer to <a href="https://stackoverflow.com/questions/1420724/cobertura-on-maven-multi-module-project">these</a> <a href="https://stackoverflow.com/questions/3459988/how-to-calculate-code-coverage-in-hudson-using-emma-for-a-multi-module-maven-proj">other</a> <a href="https://stackoverflow.com/questions/3768517/maven-cobertura-plugin-one-report-for-multimodule-project">questions</a>, and the recommendations by Crowne for <a href="http://maven.apache.org/maven-1.x/plugins/dashboard/" rel="nofollow noreferrer">Maven Dashboard</a> and <a href="http://www.sonarsource.org/" rel="nofollow noreferrer">Sonar</a>.</p> <p>I succeeded in getting a full coverage report <a href="http://cobertura.sourceforge.net/anttaskreference.html" rel="nofollow noreferrer">using pure Ant</a>. [EDIT:] I instrumented all jars from the development-runtime directory into a temporary directory; prepended the temporary directory to the classpath; then ran tests <em>from Ant</em> with <em>batch-test</em>.</p> <p>Ant can be run from Maven, but the challenge here is seamless integration (i.e., feeding all the classpath and sourcepath elements from Maven to Ant automatically), which is why I did not use Maven's facilities for this purpose.</p> <p>There are also <a href="https://stackoverflow.com/questions/2188192/running-integration-tests-with-cobertura-maven-plugin">other</a> <a href="http://www.sonatype.com/people/2009/06/integration-tests-with-maven-part-2-test-coverage-reports/" rel="nofollow noreferrer">questions</a> about integration tests. However, by default, each project's report by default only reports coverage on code in the <em>same</em> project, whereas my tests exercise code in multiple projects.</p> <p>This <a href="http://foobar.lacoctelera.net/post/2008/09/15/uso-del-plugin-cobertura-dentro-un-proyecto-multi-modulo-en" rel="nofollow noreferrer">article in Spanish</a> might be relevant. Here is another <a href="http://seamframework.org/Documentation/SeamTestCoverageWithCobertura" rel="nofollow noreferrer">Seam-specific article</a>.</p> <hr>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload