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

This widget could not be displayed.

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, *IT.java, *ITCase.java, while Surefire searches for Test*.java, *Test.java, *TestCase.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 https://bitbucket.org/atlassian/maven-clover2-plugin, 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:

 

Regards
Marek

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

30 views 3 4
Join discussion

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