Skip to content

Java-junit reporter does not create annotations in multi-module Maven projects #678

@florestan-bardeau-sg

Description

@florestan-bardeau-sg

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 ✅

  1. Event type is pull_request
  2. Permissions: checks: write, pull-requests: write
  3. XML contains valid stack traces with line numbers:
    at com***MaturityUtilsUnitTest.testtemporaryfailure(MaturityUtilsUnitTest.java:21)
    at com***MaturityUtilsUnitTest.testTranscodeMaturity(MaturityUtilsUnitTest.java:27)
    
  4. File core/common/src/test/java/.../MaturityUtilsUnitTest.java is in PR changeset
  5. File is tracked by git (verified: 1029 files found)
  6. 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-junit

Verified: Both locations exist after copy:

  • workspace/src/test/java/.../MaturityUtilsUnitTest.java
  • workspace/core/common/src/test/java/.../MaturityUtilsUnitTest.java

Still no annotations

Questions

  1. Does java-junit support multi-module Maven? The heuristic seems designed for single-module projects only.

  2. Can we configure a custom path prefix? E.g., tell the reporter to look in core/common/src/test/java instead of src/test/java.

  3. Enable debug logging? Is there a way to see which paths test-reporter is attempting to resolve?

  4. Why doesn't the file copy workaround work? Even with files at src/test/java/..., no annotations are created.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions