To get started with Clover-for-Maven, carry out the following steps.
Before you get started, add this to your .m2/settings.xml
file so you can reference Clover by its short name clover2
.
<pluginGroups> <pluginGroup>com.atlassian.maven.plugins</pluginGroup> </pluginGroups>
The quickest and easiest way to try Clover is from the command line:
mvn clean clover2:setup test clover2:aggregate clover2:clover
Goals:
You can find a report in target/site/clover
directory.
For more instructions, see the Clover-for-Maven 2 and 3 User's Guide.
For documentation presented in the standard Maven format, see the Maven Site Docs.
No coverage data?
Call the clover2:setup goal and compilation in one Maven command (e.g 'mvn clover2:setup test') and not separately (e.g. 'mvn clover2:setup; mvn test'). The clover2:setup goal puts instrumented sources into the target/clover directory and reconfigures module's source roots, so that maven-compiler-plugin picks them from the /target/clover/* and not from the /src/main/* or the /src/test/*. If you would call them separately, maven-compiler-plugin would compile non-instrumented files and you would get no coverage data.
No coverage data?
Clover uses source code instrumentation, which means that source files must be recompiled with the 'clover2:setup' goal. Ensure that you're building your project from scratch (call 'mvn clean' or do the fresh checkout) . Otherwise Maven may find your old, non-instrumented classes from a previous build and do not compile sources.
Unless first build was a full rebuild with 'clover2:setup' and all subsequent builds perform incremental compilation with 'clover2:setup'.
No coverage data?
In case you run in-container tests (e.g. using maven-cargo-plugin) or spawn new JVM processes or run tests of an application running on a remote server, you may need to add Clover's runtime JAR (com.atlassian.clover:clover) to a class path. See NoClassDefFoundError and Using Clover for web applications.
Out of memory?
Please keep in mind that Clover adds extra instructions to your classes measuring code coverage. Thus, increasing PermGen size may be necessary. See OutOfMemoryError: PermGen space.
Need more help?