Just got a strange error. Working on project using JUnit and Maven 3.0.3 I've created in my test/src/java folder one test class - ClassifierUtilTest.java
, with @Test
-annotated methods and stuff, and two utility classes, just for the use in the testing env (one with few static methods for bypassing private visibility scopes and one mock for tested interface).
It works good under Maven 3.0.3 (mvn test
), and in Eclipse 3.7 (run as / JUnit test), but when someone else tried to 'mvn test
' it with Maven 2.2.1 it failed. Apparently it tried to treat those util classes as test classes and failed due to 'no @Test
-annotated methods' and 'more than one constructor'.
It's not JUnit fault (at least it shouldn't be, maven dependency is the same, junit:junit:4.9
), so it seems to be strictly maven or maven-surefire-plugin
fault. I was wondering if there is some widely-known workaround for Maven 2.2.1 for this problem?
maven-surefire-plugin
by default runs all the classes the have Test
prefix or suffix (like yours ClassifierUtilTest
) and TestCase
suffix. Just change the name to ClassifierTestUtil
and you'll be fine.
You can also exclude certain files/directories in pom.xml
, see Inclusions and Exclusions of Tests:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<excludes>
<exclude>**/ClassifierUtilTest.java</exclude>
</excludes>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With