修改pom.xml 增加如下插件:
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.6</version>
- <configuration>
- <formats>
- <format>html</format>
- <format>xml</format>
- </formats>
- <instrumentation>
- <excludes>
- <exclude>com/**/*Test.class</exclude>
- </excludes>
- </instrumentation>
- </configuration>
- </plugin>
增加reporting配置:
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <configuration>
- <formats>
- <format>html</format>
- <format>xml</format>
- </formats>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
这下面有两种格式的report, html的可以直接在你本地浏览浏览器打开。 xml结构可以提供给第三方程序调用显示result。
有关jenkins集成cobertura请参考如下文章: