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-pluginby default runs all the classes the haveTestprefix or suffix (like yoursClassifierUtilTest) andTestCasesuffix. Just change the name toClassifierTestUtiland you’ll be fine.You can also exclude certain files/directories in
pom.xml, see Inclusions and Exclusions of Tests: