Skip to content

Commit 56fc1dc

Browse files
committed
feat(环境): 适配多模块测试
1 parent 30d36e5 commit 56fc1dc

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

.github/workflows/checker.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,51 @@ jobs:
2929
- name: Check Spotbugs
3030
run: ./mvnw spotbugs:check
3131

32-
# 添加单元测试步骤
32+
# 执行所有模块的测试
3333
- name: Run Unit Tests
3434
run: ./mvnw -B test
3535

36-
# 生成测试覆盖率报告
37-
- name: Generate Test Coverage Report
38-
run: ./mvnw -B jacoco:report
39-
40-
- name: Build with Maven
41-
run: ./mvnw -B clean package
42-
43-
# 使用 actions/test-reporter 展示测试结果
36+
# 收集所有模块的测试报告
4437
- name: Publish Test Results
4538
uses: dorny/test-reporter@v1
4639
if: always()
4740
with:
4841
name: JUnit Tests (${{ matrix.java }})
49-
path: target/surefire-reports/*.xml
42+
path: '**/target/surefire-reports/TEST-*.xml'
5043
reporter: java-junit
51-
fail-on-error: true
44+
fail-on-error: false
5245

46+
- name: Build with Maven
47+
run: ./mvnw -B clean package
48+
49+
# 上传所有模块的测试结果
5350
- name: Upload Test Results
5451
if: always()
5552
uses: actions/upload-artifact@v4
5653
with:
5754
name: test-results-${{ matrix.java }}
58-
path: target/surefire-reports/
55+
path: |
56+
**/target/surefire-reports/
57+
**/target/site/surefire-report.html
58+
59+
# 收集所有模块的覆盖率报告
60+
- name: Generate Test Coverage Report
61+
run: ./mvnw -B jacoco:report
5962

6063
- name: Upload Coverage Report
6164
if: matrix.java == '8'
6265
uses: actions/upload-artifact@v4
6366
with:
6467
name: coverage-report
65-
path: target/site/jacoco/
68+
path: |
69+
**/target/site/jacoco/
70+
**/target/site/jacoco/jacoco.xml
6671
6772
- name: Report Coverage to Codecov
6873
if: matrix.java == '8'
6974
uses: codecov/codecov-action@v3
7075
with:
71-
file: target/site/jacoco/jacoco.xml
76+
files: '**/target/site/jacoco/jacoco.xml'
7277

7378
dependency-check:
7479
runs-on: ubuntu-latest
@@ -90,4 +95,4 @@ jobs:
9095
uses: actions/upload-artifact@v4
9196
with:
9297
name: dependency-check-report
93-
path: target/dependency-check-report.html
98+
path: '**/target/dependency-check-report.html'

pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,21 @@
240240
</formats>
241241
</configuration>
242242
</plugin>
243+
244+
<!-- Surefire Plugin -->
245+
<plugin>
246+
<groupId>org.apache.maven.plugins</groupId>
247+
<artifactId>maven-surefire-plugin</artifactId>
248+
<version>3.2.5</version>
249+
<configuration>
250+
<includes>
251+
<include>**/*Test.java</include>
252+
<include>**/*Tests.java</include>
253+
<include>**/Test*.java</include>
254+
</includes>
255+
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
256+
</configuration>
257+
</plugin>
243258
</plugins>
244259
</build>
245260

0 commit comments

Comments
 (0)