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, *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
Community showcase
Posted yesterday in Canada

Happy New Year - First AUG of the year - great success

Hi Everyone, Hope everyone had a great holiday season and is ready for an exciting 2019.  We had our first AUG last night featuring Tempo Timesheets.  A great presentation and lots of int...

15 views 0 1
View post

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