Guides / Collect test results
Collect test results
Most test runners can write their results as JUnit XML. The
test-results step uploads those files, so hatchrun has a result
for each test.
Prerequisites
Section titled “Prerequisites”- A test runner that writes JUnit XML. Most do with a flag or a
reporter: Jest with
jest-junit, pytest with--junitxml, cargo-nextest with a JUnit profile, Go withgotestsum.
-
Make the test runner write JUnit XML
Section titled “Make the test runner write JUnit XML”Point it at one directory, here
reports/:Terminal window pytest --junitxml=reports/junit.xml -
Add the test-results step
Section titled “Add the test-results step”The value is a file or a directory:
.hatchrun/config.yml jobs:test:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v5- run: pip install -r requirements.txt- run: pytest --junitxml=reports/junit.xml- test-results: reports -
Validate
Section titled “Validate”Terminal window hatchrun validate
Good to know
Section titled “Good to know”test-resultstakes one path and nothing else.- Built-in steps take no
if:. Whethertest-resultsruns after a failed test step will be settled with the runner work.