-
Notifications
You must be signed in to change notification settings - Fork 275
Description
java-junit reporter does not create annotations in multi-module Maven projects
Problem
test-reporter successfully generates test reports but fails to create any annotations on source files in multi-module Maven projects.
Environment
- Version:
dorny/test-reporter@v2 - Specific Version*:
V2.0.0 - Reporter:
java-junit - Event:
pull_request - Maven: Multi-module project with submodules
Project Structure
workspace/
├── pom.xml (parent)
└── core/
└── common/ ← Maven submodule
├── pom.xml
├── src/test/java/com/***/***/common/utils/
│ └── MaturityUtilsUnitTest.java
└── target/surefire-reports/
└── TEST-...MaturityUtilsUnitTest.xml
File locations:
- Test source:
core/common/src/test/java/com/***/***/common/utils/MaturityUtilsUnitTest.java - XML report:
core/common/target/surefire-reports/TEST-***MaturityUtilsUnitTest.xml
Verified Working ✅
- Event type is
pull_request - Permissions:
checks: write,pull-requests: write - XML contains valid stack traces with line numbers:
at com***MaturityUtilsUnitTest.testtemporaryfailure(MaturityUtilsUnitTest.java:21) at com***MaturityUtilsUnitTest.testTranscodeMaturity(MaturityUtilsUnitTest.java:27) - File
core/common/src/test/java/.../MaturityUtilsUnitTest.javais in PR changeset - File is tracked by git (verified: 1029 files found)
- Test report summary appears in PR ✅
Not Working ❌
No annotations created. test-reporter logs show:
Found 1029 files tracked by GitHub
Using test report parser 'java-junit'
Creating test report Core Common Tests
(No "Creating X annotations..." message)
Root Cause
From java-junit documentation:
"Java stack traces don't contain a full path to the source file. Some heuristic was necessary..."
The heuristic assumes:
Package: com.sgcib.cops.common.utils
→ Constructs path: src/test/java/com/***/***/****/utils/MaturityUtilsUnitTest.java
Actual file location:
core/common/src/test/java/com/***/***/***/utils/MaturityUtilsUnitTest.java
Path mismatch → No annotations created.
Attempted Solutions
1. Changed working-directory to submodule
working-directory: ***/common❌ No annotations
2. Changed working-directory to workspace root
working-directory: ${{ github.workspace }}❌ No annotations
3. Copied files to workspace root before test-reporter
- run: |
mkdir -p src/test/java/com/***/***/common
cp -r core/common/src/test/java/com/***/***/common/* \
src/test/java/com/***/***/common/
- uses: dorny/test-reporter@v1
with:
path: 'core/common/target/surefire-reports/TEST-*.xml'
reporter: java-junitVerified: Both locations exist after copy:
workspace/src/test/java/.../MaturityUtilsUnitTest.java✅workspace/core/common/src/test/java/.../MaturityUtilsUnitTest.java✅
❌ Still no annotations
Questions
-
Does
java-junitsupport multi-module Maven? The heuristic seems designed for single-module projects only. -
Can we configure a custom path prefix? E.g., tell the reporter to look in
core/common/src/test/javainstead ofsrc/test/java. -
Enable debug logging? Is there a way to see which paths test-reporter is attempting to resolve?
-
Why doesn't the file copy workaround work? Even with files at
src/test/java/..., no annotations are created.