联系
Knight's Tale » 技术

Jenkins:为你的项目添加覆盖率报表

2014-08-28 21:18

Pom文件修改

为你的POM添加

<!-- 覆盖率 -->
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <encoding>UTF-8</encoding>
        <aggregate>true</aggregate>
        <formats>
            <format>xml</format>
            <format>html</format>
        </formats>
        <instrumentation>
            <excludes>
                <exclude>**/*Proto.class</exclude>
                <exclude>**/*Proto$*.class</exclude>
                <exclude>**/*Test.class</exclude>
                <exclude>**/*Controller.class</exclude>
                <exclude>**/*Vo.class</exclude>
                <exclude>**/*Form.class</exclude>
            </excludes>
        </instrumentation>
    </configuration>
</plugin>

具体可参考:

https://github.com/knightliao/disconf/blob/master/disconf-web/pom.xml

jenknis支持

先写生成覆盖率的脚本:

覆盖率报告:

结果