Using Clover with Maven + surefire-test + inner test classes
If you use Maven with the surefire-test plugin, its default filter setting for searching test classes is to skip inner classes:
<excludes>
<exclude>**/*$*</exclude>
</excludes>
In case when you have inner classes defined in your JUnit TestCases and you have configured a Surefire plugin to run your inner classes as well, you might get an error like this:
------------------------------------------------------------------------------- Test set: TestUtils$__CLR2_6_34a4agh7gevmc ------------------------------------------------------------------------------- Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.094 sec <<< FAILURE! initializationError(TestUtils$__CLR2_6_34a4agh7gevmc) Time elapsed: 0.016 sec <<< ERROR! java.lang.Exception: Test class should have exactly one public constructor at org.junit.runners.BlockJUnit4ClassRunner.validateOnlyOneConstructor(BlockJUnit4ClassRunner.java:143)
This is because Clover generates inner class for each class (test or application code). In order to fix a problem, you have to change your pom.xml and filter out from your test scope any inner classes beginning with __CLR.
For example:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<properties>
<excludes>
<exclude>**/*$__CLR*</exclude>
</excludes>
</properties>
</plugin>
</plugins>
</build>