1. 写单元测试遇到的问题 , 单元测试工具clover
报错:
java.lang.NoClassDefFoundError: com_cenqua_clover/CoverageRecorder
看到com_cenqua_clover/CoverageRecorder 这个是写单元测试导致报错
需要将单元测试关掉就可以了
写单元测试的时候为了防止冲突了编译问题需要做设置,设置单元测试的文件的编辑位置
上图单元测试的文件的编译位置的设置
单元测试中maven的设置
<!--start junit测试用 -->
<build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<!--start junit测试用 -->
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
<!--end junit测试用 -->
<resources>
<resource>
<directory>${basedir}/src/main/resource</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>${basedir}/src/test/resource</directory>
<targetPath>${basedir}/target/test-classes</targetPath>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<!-- skipTests为true发布时候自动跳过单元测试 -->
<skipTests>true</skipTests>
<includes>
<include>**/*Tests.java</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<!-- <configLocation>${basedir}/springside-findbugs.xml</configLocation>-->
<threshold>High</threshold>
<effort>Default</effort>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<xmlOutput>true</xmlOutput>
<formats><format>html</format></formats>
</configuration>
</plugin>
</plugins>
</build>