| 2025.12.08 | JaCoCo & JUnitTest

This commit is contained in:
Moshow郑锴
2025-12-07 11:34:37 +08:00
parent f99438718a
commit 5131a4a3a3
14 changed files with 1786 additions and 83 deletions

113
pom.xml
View File

@@ -37,11 +37,37 @@
<artifactId>jsqlparser</artifactId>
<version>5.3</version>
</dependency>
<!-- JUnit 5 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<!-- Mockito for JUnit 5 -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Boot Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -163,6 +189,89 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- JaCoCo Maven Plugin for Code Coverage -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<!-- 准备JaCoCo代理用于收集覆盖率数据 -->
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- 生成覆盖率报告 -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<!-- 检查覆盖率阈值 -->
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<!-- 指令覆盖率最低要求 -->
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.00</minimum>
</limit>
<!-- 分支覆盖率最低要求 -->
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.00</minimum>
</limit>
<!-- 类覆盖率最低要求 -->
<limit>
<counter>CLASS</counter>
<value>COVEREDRATIO</value>
<minimum>0.00</minimum>
</limit>
<!-- 方法覆盖率最低要求 -->
<limit>
<counter>METHOD</counter>
<value>COVEREDRATIO</value>
<minimum>0.00</minimum>
</limit>
<!-- 行覆盖率最低要求 -->
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.00</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
<configuration>
<!-- 排除不需要生成覆盖率报告的类 -->
<excludes>
<exclude>**/Application.class</exclude>
<exclude>**/config/**</exclude>
<exclude>**/dto/**</exclude>
<exclude>**/vo/**</exclude>
<exclude>**/entity/**</exclude>
<exclude>**/util/exception/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>