你与别人花费一样的时间,因为别人用心,而你吊儿郎当,所以到了最后检验成果的时候,别人成功,而你除了赔了时间之后,一无所得。——飞行员舒克

文档:

JaCoCo - Maven Plug-in

首先配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>

然后执行mvn test

target/site下面就会生成测试报告

比如我这里

/Users/achao/IdeaProjects/stream-query/stream-plugin/stream-plugin-mybatis-plus/target/site/checkstyle.html

Element Missed Instructions Cov. Missed Branches Cov. Missed Cxty Missed Lines Missed Methods Missed Classes
org.dromara.streamquery.stream.plugin.mybatisplus 427/1996 82% 58/84 59% 86 297 97 539 35 226 0 10
org.dromara.streamquery.stream.plugin.mybatisplus.engine.methods 62/443 87% 8/12 60% 9 22 13 100 2 12 0 3
org.dromara.streamquery.stream.plugin.mybatisplus.engine.interceptor 27/27 58% 3/3 50% 5 7 7 16 2 4 0 1
org.dromara.streamquery.stream.plugin.mybatisplus.engine.configuration 447/447 97% 6/32 84% 7 59 5 140 1 40 0 9
org.dromara.streamquery.stream.plugin.mybatisplus.engine.utils 0/0 68% 3/3 25% 3 5 1 7 1 3 0 1
org.dromara.streamquery.stream.plugin.mybatisplus.engine.enumration 50/50 94% 0/0 n/a 1 5 1 11 1 5 0 1
org.dromara.streamquery.stream.plugin.mybatisplus.engine.handler 54/54 100% 4/4 100% 0 4 0 15 0 2 0 1
org.dromara.streamquery.stream.plugin.mybatisplus.engine.mapper 38/38 100% 0/0 50% 1 5 0 9 0 4 0 2
org.dromara.streamquery.stream.plugin.mybatisplus.engine.constant 0/0 100% 0/0 n/a 0 1 0 1 0 1 0 1
Total 530 of 3,617 85% 79 of 216 63% 112 405 124 838 42 297 0 29