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
| Runner | JUnit flag |
|---|---|
| pytest | --junitxml=results/pytest.xml |
| Newman | -r junit --reporter-junit-export results/newman.xml |
| Hurl | --report-junit results/hurl.xml |
| Jest | jest-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-junitGotchas
- 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
How to Run Postman Collections With Newman in CIRun a Postman collection in GitHub Actions with the Newman CLI, passing an environment file and emitting a JU…
How to Run REST API Tests With pytest and requests in CIRun integration tests against a REST API in GitHub Actions using pytest and the requests library, with a JUni…
How to Run Data-Driven API Tests in CIRun the same API test over many input rows in GitHub Actions with pytest parametrize or a Newman CSV data fil…