首页 > Test class should have exactly one public constructor解决办法

Test class should have exactly one public constructor解决办法

测试类用的junit,在eclipse中执行ok,在maven编译就挂

Error MessageTest class should have exactly one public constructor
Stacktracejava.lang.Exception: Test class should have exactly one public constructorat 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配置中增加以下内容

  

**/*$*.java

 

<plugin><groupId>org.apache.maven.pluginsgroupId><artifactId>maven-surefire-pluginartifactId><configuration><includes><include>**/*Test*.javainclude>includes><excludes><include>**/test/**/*Test*.javainclude><include>**/servicetest/**/*.javainclude><include>**/*$*.javainclude>excludes><testFailureIgnore>truetestFailureIgnore><argLine>-Xmx1024margLine>configuration>

 

应该是junit和maven的surefire plugin不兼容导致的

转载于:https://www.cnblogs.com/forward/archive/2012/09/21/2697330.html

更多相关:

  •    5.5 计数器    让我们在首页上加上一个计数器。这个例子已经被讲过多次了,但是还是有利于演示怎样读写文件以及创建自己的函数。counter.inc包含以下代码: