cobertura插件应用过程

代码覆盖率 只能覆盖字段声明,构造函数或方法体。

引用:https://blog.csdn.net/bingleihenshang/article/details/102885020

1.引入插件(配合maven使用)

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
                </configuration>
            </plugin>

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <formats>
                        <format>html</format>
                        <format>xml</format>
                    </formats>
                    <check/>
                </configuration>
                <!--executions 在构建生命周期中执行一组目标的配置,每个目标有不同配置-->
                <executions>
                    <execution>
                        <!--phase绑定了目标的构建生命周期阶段,如果省略,目标会被绑定到源数据里配置的默认阶段-->
                        <phase>package</phase>
                        <!-- 配置的执行目标 -->
                        <goals>
                            <goal>clean</goal>
                            <goal>cobertura</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

2.应用在程序中

跑完测试后会出现如下图:

导出和查看生成的html文件

找到保存的目录文件,打开index.html


 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章