Skip to content
Latchkey

How to Publish an API Test JUnit Report in CI

A JUnit XML report turns raw test output into a structured summary GitHub can render per run.

Have the runner write JUnit XML (--junitxml, -r junit, Surefire), upload it as an artifact, and use a publisher action to surface it on the run.

Common flags

RunnerJUnit flag
pytest--junitxml=results/pytest.xml
Newman-r junit --reporter-junit-export results/newman.xml
Hurl--report-junit results/hurl.xml
Jestjest-junit reporter

Workflow

.github/workflows/ci.yml
jobs:
  api:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pytest --junitxml=results/pytest.xml
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: api-junit
          path: results/pytest.xml
      - uses: dorny/test-reporter@v1
        if: always()
        with:
          name: API tests
          path: results/pytest.xml
          reporter: java-junit

Gotchas

  • Guard the upload and reporter steps with if: always() so results still publish when tests fail.
  • Write reports to a stable folder so the same glob works across runners.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →