I'm trying to optimize my maven build cycle with clover. I want to eventually use clover to instrument my code so 'mvn test' will just run tests related to classes that have changed.
But for my first step, I would just like to use clover to run unit tests that have failed during the last test run. I tried to run:
mvn clover2-plugin:optimize test clover2-plugin:snapshot
But I don't think it's behaving properly -- it's still running all the tests each time I run it.
I'm assuming the snapshot step is not working properly. I see this in my console:
INFO] --- maven-clover2-plugin:3.1.0:snapshot (default-cli) @ webapp ---
[INFO] /webapp/target/clover/clover.db does not exist. Skipping snapshot creation.
Below is the full output my maven cycle:
INFO] --- maven-clover2-plugin:3.1.0:optimize (default-cli) @ webapp ---
[INFO] Adding fileset: directory=/webapp/inputvalidation/src/test/java, includes=[**/*Test.java], excludes=[**/*IntegrationTest.java, **/*OnlineTest.java, **/*LoadTest.java]
[INFO] Clover was unable to save any time on this optimized test run.
[INFO] Clover included 27 test classes in this run (total # test classes : 27)
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ webapp ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /webapp/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ webapp ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ webapp ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ webapp ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.11:test (default-test) @ webapp ---
[INFO] Surefire report directory: /webapp /target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.BlahTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.234 sec
....
Results :
Tests run: 55, Failures: 0, Errors: 0, Skipped: 3
[INFO]
[INFO] --- maven-clover2-plugin:3.1.0:snapshot (default-cli) @ webapp ---
[INFO] /webapp/target/clover/clover.db does not exist. Skipping snapshot creation.
So the next time when I try to run: mvn clover2-plugin:optimize test clover2-plugin:snapshot
It runs all the tests again.
Help?
Hi Bob,
Clover uses source code instrumentation technique in order to get code coverage (which is also necessary for optimization of unit tests). It means that you have to use clover2:setup goal and compile an instrumented version of your source code.
Please try the following:
mvn clean clover2:setup clover2:optimize test clover2:snapshot (first run with 'clean' just to get full rebuild, Clover will include all tests for execution)
mvn clover2:setup clover2:optimize test clover2:snapshot (next runs without clean so we have incremental build after any changes in code, Clover will analyze changes in application code and unit tests and select proper set of unit tests for execution)
Regards
Marek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.