surefire 是单测插件, 执行哪些单测. cobertura 是覆盖率统计插件,对class进行注入,然后统计哪些代码执行了,最终生成xml,二次开发,或者直接html展示. 辅助surefire使用.
mvn -B install -Dmaven.test.skip=true -Dautoconfig.skip mvn -B org.codehaus.mojo:cobertura-maven-plugin:2.7:cobertura -Dmaven.test.failure.ignore=true 执行的时候会不ignoretest.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.16</version> <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit4</artifactId> <version>2.16</version> </dependency> </dependencies> <configuration> <includes> <include>com/mocktest/**/*Test.java</include> </includes> <excludes> <exclude>**/*NoRunTest.java</exclude> <exclude>**/*InteTest.java</exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.6</version> <configuration> <instrumentation> <excludes> <!-- <exclude>com/vo/*.class</exclude> --> </excludes> </instrumentation> </configuration> </plugin>
surefire 和 cobertura 区别,多模块单测的问题见另外文章
最新推荐文章于 2021-06-08 22:09:34 发布