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 vote

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 41m ago in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

38 views 3 3
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