maven,jacoco

jacoco 配置

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <project xmlns="http://maven.apache.org/POM/4.0.0"
  3          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5     <modelVersion>4.0.0</modelVersion>
  6 
  7     <groupId>cn.youzan.ycm</groupId>
  8     <artifactId>jacoco_test</artifactId>
  9     <version>1.0-SNAPSHOT</version>
 10 
 11     <properties>
 12         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 13         <compiler.source>1.8</compiler.source>
 14         <compiler.target>1.8</compiler.target>
 15         <junit.version>4.12</junit.version>
 16     </properties>
 17 
 18     <dependencies>
 19         <dependency>
 20             <groupId>org.jacoco</groupId>
 21             <artifactId>jacoco-maven-plugin</artifactId>
 22             <version>0.7.9</version>
 23         </dependency>
 24         <dependency>
 25             <groupId>junit</groupId>
 26             <artifactId>junit</artifactId>
 27             <version>${junit.version}</version>
 28             <scope>test</scope>
 29         </dependency>
 30     </dependencies>
 31 
 32     <build>
 33         <finalName>wulei</finalName>
 34         <plugins>
 35             <plugin>
 36                 <inherited>true</inherited>
 37                 <groupId>org.apache.maven.plugins</groupId>
 38                 <artifactId>maven-compiler-plugin</artifactId>
 39                 <version>3.1</version>
 40                 <configuration>
 41                     <source>${compiler.source}</source>
 42                     <target>${compiler.target}</target>
 43                     <encoding>${project.build.sourceEncoding}</encoding>
 44                 </configuration>
 45             </plugin>
 46             <plugin>
 47                 <groupId>org.jacoco</groupId>
 48                 <artifactId>jacoco-maven-plugin</artifactId>
 49                 <version>0.7.9</version>
 50                 <configuration>
 51                     <rules>
 52                         <rule implementation="org.jacoco.maven.RuleConfiguration">
 53                             <element>BUNDLE</element>
 54                             <limits>
 55                                 <!-- 指定方法覆盖到80% -->
 56                                 <limit implementation="org.jacoco.report.check.Limit">
 57                                     <counter>METHOD</counter>
 58                                     <value>COVEREDRATIO</value>
 59                                     <minimum>0.80</minimum>
 60                                 </limit>
 61                                 <!-- 指定指令覆盖到80% -->
 62                                 <limit implementation="org.jacoco.report.check.Limit">
 63                                     <counter>INSTRUCTION</counter>
 64                                     <value>COVEREDRATIO</value>
 65                                     <minimum>0.80</minimum>
 66                                 </limit>
 67                                 <!-- 指定行覆盖到80% -->
 68                                 <limit implementation="org.jacoco.report.check.Limit">
 69                                     <counter>LINE</counter>
 70                                     <value>COVEREDRATIO</value>
 71                                     <minimum>0.80</minimum>
 72                                 </limit>
 73                                 <!-- 指定类覆盖到100%,不能遗失任何类 -->
 74                                 <limit implementation="org.jacoco.report.check.Limit">
 75                                     <counter>CLASS</counter>
 76                                     <value>MISSEDCOUNT</value>
 77                                     <maximum>0</maximum>
 78                                 </limit>
 79                             </limits>
 80                         </rule>
 81                     </rules>
 82                 </configuration>
 83                 <executions>
 84                     <execution>
 85                         <id>prepare-agent</id>
 86                         <goals>
 87                             <goal>prepare-agent</goal>
 88                         </goals>
 89                     </execution>
 90                     <execution>
 91                         <id>check</id>
 92                         <goals>
 93                             <goal>check</goal>
 94                         </goals>
 95                     </execution>
 96                     <execution>
 97                         <id>report</id>
 98                         <phase>test</phase>
 99                         <goals>
100                             <goal>report</goal>
101                         </goals>
102                         <configuration>
103                             <dataFile>target/jacoco.exec</dataFile>
104                             <outputDirectory>target/jacoco-wulei</outputDirectory>
105                             <includes>
106                                 <include>**/Func**</include>
107                             </includes>
108                         </configuration>
109                     </execution>
110                 </executions>
111             </plugin>
112         </plugins>
113     </build>
114 </project>

 

posted @ 2020-09-02 14:43  爱寂寞撒的谎言  阅读(309)  评论(0编辑  收藏  举报