Skip to content

Commit 4a7f3ac

Browse files
committed
feat: optimize test
1 parent 3fbb6d0 commit 4a7f3ac

1 file changed

Lines changed: 46 additions & 21 deletions

File tree

pom.xml

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<maven.compiler.release>17</maven.compiler.release>
8888

8989
<maven.test.skip>false</maven.test.skip>
90+
<maven.ignore.testfailure>false</maven.ignore.testfailure>
9091
<maven.deploy.skip>false</maven.deploy.skip>
9192
<maven.compiler.version>3.11.0</maven.compiler.version>
9293
<maven.surefire.version>3.0.0-M9</maven.surefire.version>
@@ -99,6 +100,7 @@
99100
<maven.exec.version>3.1.0</maven.exec.version>
100101
<maven.gpg.version>3.1.0</maven.gpg.version>
101102

103+
<jacoco.version>0.8.11</jacoco.version>
102104
<central-publishing-maven-plugin.version>0.7.0</central-publishing-maven-plugin.version>
103105
<exec.maven.version>3.1.0</exec.maven.version>
104106
<junit.version>5.14.2</junit.version>
@@ -137,17 +139,10 @@
137139
<version>${junit.version}</version>
138140
<scope>test</scope>
139141
</dependency>
140-
<!-- 保留 JUnit 4 测试 todo 删除-->
141-
<!-- <dependency>-->
142-
<!-- <groupId>junit</groupId>-->
143-
<!-- <artifactId>junit</artifactId>-->
144-
<!-- <version>4.13.2</version>-->
145-
<!-- <scope>test</scope>-->
146-
<!-- </dependency>-->
147142
<dependency>
148143
<groupId>org.jacoco</groupId>
149144
<artifactId>org.jacoco.agent</artifactId>
150-
<version>0.8.11</version>
145+
<version>${jacoco.version}</version>
151146
<classifier>runtime</classifier>
152147
<scope>test</scope>
153148
</dependency>
@@ -183,14 +178,14 @@
183178
<argLine>
184179
--add-opens java.base/java.lang=ALL-UNNAMED
185180
--add-opens java.base/java.util=ALL-UNNAMED
181+
--add-opens java.base/java.io=ALL-UNNAMED
186182
</argLine>
187183
<testFailureIgnore>${maven.ignore.testfailure}</testFailureIgnore>
188184
<skipTests>false</skipTests>
189-
<systemPropertyVariables>
190-
<jacoco-agent.destfile>${project.build.directory}/coverage.exec
191-
</jacoco-agent.destfile>
192-
</systemPropertyVariables>
193185
<reportsDirectory>../../site/junit</reportsDirectory>
186+
<useSystemClassLoader>false</useSystemClassLoader>
187+
<forkCount>1</forkCount>
188+
<reuseForks>true</reuseForks>
194189
</configuration>
195190
</plugin>
196191
<plugin>
@@ -256,22 +251,22 @@
256251
<plugin>
257252
<groupId>org.jacoco</groupId>
258253
<artifactId>jacoco-maven-plugin</artifactId>
259-
<version>0.8.8</version>
254+
<version>${jacoco.version}</version>
260255
<configuration>
261256
<skip>false</skip>
257+
<destFile>${project.build.directory}/coverage.exec</destFile>
258+
<append>true</append>
262259
</configuration>
263260
<executions>
264261
<execution>
265-
<id>default-instrument</id>
262+
<id>prepare-agent</id>
266263
<goals>
267-
<goal>instrument</goal>
268-
</goals>
269-
</execution>
270-
<execution>
271-
<id>default-restore-instrumented-classes</id>
272-
<goals>
273-
<goal>restore-instrumented-classes</goal>
264+
<goal>prepare-agent</goal>
274265
</goals>
266+
<configuration>
267+
<propertyName>surefireArgLine</propertyName>
268+
<destFile>${project.build.directory}/coverage.exec</destFile>
269+
</configuration>
275270
</execution>
276271
<execution>
277272
<id>report</id>
@@ -284,13 +279,39 @@
284279
<outputDirectory>../../site/${project.artifactId}</outputDirectory>
285280
</configuration>
286281
</execution>
282+
<execution>
283+
<id>aggregate</id>
284+
<phase>verify</phase>
285+
<goals>
286+
<goal>report-aggregate</goal>
287+
</goals>
288+
</execution>
287289
</executions>
288290
</plugin>
289291
<plugin>
290292
<groupId>org.codehaus.mojo</groupId>
291293
<artifactId>exec-maven-plugin</artifactId>
292294
<version>${exec.maven.version}</version>
293295
</plugin>
296+
<plugin>
297+
<groupId>org.apache.maven.plugins</groupId>
298+
<artifactId>maven-failsafe-plugin</artifactId>
299+
<version>${maven.failsafe.version}</version>
300+
<configuration>
301+
<argLine>
302+
--add-opens java.base/java.lang=ALL-UNNAMED
303+
--add-opens java.base/java.util=ALL-UNNAMED
304+
</argLine>
305+
</configuration>
306+
<executions>
307+
<execution>
308+
<goals>
309+
<goal>integration-test</goal>
310+
<goal>verify</goal>
311+
</goals>
312+
</execution>
313+
</executions>
314+
</plugin>
294315
</plugins>
295316
</pluginManagement>
296317

@@ -311,6 +332,10 @@
311332
<groupId>org.jacoco</groupId>
312333
<artifactId>jacoco-maven-plugin</artifactId>
313334
</plugin>
335+
<plugin>
336+
<groupId>org.apache.maven.plugins</groupId>
337+
<artifactId>maven-failsafe-plugin</artifactId>
338+
</plugin>
314339
</plugins>
315340
</build>
316341

0 commit comments

Comments
 (0)