-
Type:
Suggestion
-
Resolution: Fixed
-
Component/s: Documentation
-
None
Some background:
Clover's build optimization works by knowing which tests, cover which code. The basic steps involved are:
1) A full build with clover (clover2:setup) is performed and all tests are run
2) A clover snapshot file (clover2:snapshot) is created - this holds the mapping of tests to code
3) You make changes to one or more source files
4) You rebuild (either full or partial), and clover notices which files have changed
5) The snapshot file is used to determine which tests will be run next, or in which order they will run (clover2:optimize)
6) Tests are run
7) The snapshot file is updated with any new coverage data (clover2:snapshot)
8) Go to 3.
The simplest way to take advantage of Test Optimization with Clover is to run the following command line:
mvn clover2:setup clover2:optimize test clover2:snapshot
Alternatively, add the following profile to your pom.xml:
<profile>
<id>clover.optimize</id>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<id>clover</id>
<goals>
<goal>clean</goal>
<goal>setup</goal>
<goal>optimize</goal>
<goal>snapshot</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
This can then be invoked via:
mvn test -Pclover.optimize
NB: If you run mvn clean, without specifying an alternate location for the snapshot file, -Dmaven.clover.snapshot=/path/to/snapshot.db, no build optimization will be done as the snapshot file will have been deleted.