Skip to content

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.

  • 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 with gotestsum.
  1. Point it at one directory, here reports/:

    Terminal window
    pytest --junitxml=reports/junit.xml
  2. The value is a file or a directory:

    .hatchrun/config.yml
    jobs:
    test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v5
    - run: pip install -r requirements.txt
    - run: pytest --junitxml=reports/junit.xml
    - test-results: reports
  3. Terminal window
    hatchrun validate
  • test-results takes one path and nothing else.
  • Built-in steps take no if:. Whether test-results runs after a failed test step will be settled with the runner work.