Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Maven Clover: mvn clover:optimize clover:snapshot

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?

1 answer

0 votes

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

440 views 5 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you