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

Using Clover with Maven 2 for integration tests

David Rand July 12, 2011

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
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 25, 2012

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

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 26, 2012

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events