Using Clover with Maven 2 for integration tests

I know that Clover can be used for unit tests in a Maven build. The tests are executed by the Maven Surefire Plugin. However, I need to use Clover for integration tests, which are executed by the Maven Failsafe Plugin. Is this possible? Please advise. Thanks.

1 answer

0 votes

Hi David,

Sure, it is possible to use Clover with the Maven Failsafe Plugin.

However, you have to remember about few differences between Failsafe and Surefire:

  • Failsafe stores reports in target/failsafe-reports directory, while Surefire in target/surefire-reports
  • Failsafe searches for following test classes: <tt>IT*.java, *, *, while Surefire searches for Test*.java, *, *</tt>
  • <tt>Failsafe is bound to integration-test phase, while Surefire to test phase</tt>

Therefore you have to reconfigure Clover in pom.xml:

  • use the <reportDescriptor> configuration property for maven-clover2-plugin and point to XML file which will contain an Ant target named "current" and/or "historical", which will call the <clover-report> task
    • the <clover-report> task should have <testsources/> tag with include patterns for Failsafe
    • the <clover-report> task should have <testresults/> tag pointing to Failsafe report directory
  • Clover should generate report after integration tests, so either bind it to verify phase in pom.xml or call clover2:clover goal from command line, like:
    mvn clean clover2:setup verify clover2:aggregate clover2:clover

Optionally, if you wish to have a consolidated Clover report for both Surefire and Failsafe run:

  • set <reportsDirectory> for both plugins to the same location
  • enable both Surefire and Failsafe in the same build


I have prepared a sample project showing Surefire and Failsafe usage. Go to the, clone this repository, go to the src/it/surefire-and-failsafe-plugins folder and run mvn command with goals as specified in goals.txt file.

See also:



Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

183 views 0 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you