Test class should have exactly one public constructor解决办法
测试类用的junit,在eclipse中执行ok,在maven编译就挂
Error Message
Test class should have exactly one public constructor
Stacktrace
java.lang.Exception: Test class should have exactly one public constructor
at org.junit.runners.BlockJUnit4ClassRunner.validateOnlyOneConstructor(BlockJUnit4ClassRunner.java:136)
at org.junit.runners.BlockJUnit4ClassRunner.validateConstructor(BlockJUnit4ClassRunner.java:125)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:114)
解决办法,在pom.xml中的maven-surefire-plugin配置中增加以下内容
<include>**/*$*.java</include>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <includes> <include>**/*Test*.java</include> </includes> <excludes> <include>**/test/**/*Test*.java</include> <include>**/servicetest/**/*.java</include> <include>**/*$*.java</include> </excludes> <testFailureIgnore>true</testFailureIgnore> <argLine>-Xmx1024m</argLine> </configuration>
应该是junit和maven的surefire plugin不兼容导致的
forward.molly.宝儿 独自行走