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


 

 

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