CICD-065 · Write a test report as JUnit XML
Encyclopedia · Python CI and uv · All snippets
Previous · CICD-064 · Next · CICD-066
1. Where it fits
- Placement In the CI test step after locked dependency installation.
- Prerequisites uv or Python dependencies pinned with fixture application and tests.
- Platforms local-linux, github-actions, gitea-actions.
2. Copy the snippet
bash
mkdir -p reports
uv run --locked pytest --junitxml=reports/pytest.xml3. How it works
pytest writes a JUnit report while reporting assertion failures through its process exit code. The report path must exist and upload conditions need to handle failed tests.
The report and the process exit code serve different purposes.
flowchart TD N1["Pytest run"] N2["Test result"] N1 --> N2 N3["JUnit file"] N1 --> N3 N4["CI gate"] N2 --> N4 N5["Report upload"] N3 --> N5
4. Verify the result
Upload the report even when tests fail using the platform's failure condition.
Validation syntax-validated (Bash parse). Status definitions.