How can I exclude integration tests from a Clover build?

Q: I use Maven and Clover, but I do not want my integration tests to be executed. How can I disable them?

There are several options:

Skip integration tests with maven-failsafe-plugin

If your integration tests are run by the maven-failsafe-plugin, pass:

mvn ... -DskipITs=true

Do not run the integration-test phase at all

Automatic Clover integration on a CI server typically runs the verify phase, which executes integration tests. If you drive Clover yourself and stop at test, the integration-test phase is never reached:

mvn clean clover:setup test clover:aggregate clover:clover

Use exclusion patterns

Alternatively, define exclusion patterns for the maven-surefire-plugin or maven-failsafe-plugin so that integration tests are not selected. See Using with Surefire and Failsafe plugins.

Excluding sources from the report only

If you want to keep running the tests, but exclude some source files from the report, define the exclusions in the report configuration. The <clover-report> task accepts a nested <fileset> inside its <current> element, which controls which source files are included - only classes coming from the source files in the fileset end up in the report:

<clover-report>
  <current outfile="clover_html">
    <fileset dir="src/main/java">
      <exclude name="**/*IT.java"/>
    </fileset>
    <format type="html"/>
  </current>
</clover-report>