Python

Test Suite Monitoring for pytest

Monitor your pytest test suite health with TestGlance

Get Started in 3 Steps

  1. 1Run pytest with the `--junitxml` flag to output JUnit XML: `pytest --junitxml=test-results/pytest.xml`
  2. 2No extra packages needed — JUnit XML output is built into pytest
  3. 3Add the TestGlance GitHub Action to your CI workflow

Reporter Configuration

pytest --junitxml=test-results/pytest.xml

GitHub Actions Workflow

# .github/workflows/test.yml
name: Tests
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install -r requirements.txt
      - name: Run tests
        run: pytest --junitxml=test-results/pytest.xml
      - name: Report to TestGlance
        if: always()
        uses: testglance/action@v1
        with:
          api-key: ${{ secrets.TESTGLANCE_API_KEY }}
          report-path: test-results/pytest.xml

What You Get

  • Flaky test detection — automatically identify tests that pass and fail intermittently
  • Duration trends — track which tests are getting slower over time
  • Health score — a single metric summarizing your test suite reliability
  • CI summary — rich test result summaries directly in your GitHub Actions runs

FAQ

How do I generate JUnit XML from pytest?

Use the built-in `--junitxml` flag: `pytest --junitxml=test-results/pytest.xml`. No additional packages are required.

Does TestGlance work with pytest-xdist parallel tests?

Yes. When using pytest-xdist for parallel execution, the JUnit XML report still captures all test results. TestGlance processes the combined report normally.

Can I monitor pytest fixture setup time?

TestGlance tracks individual test durations from the JUnit XML report, which includes fixture setup and teardown time. Slow fixtures will show up as slow tests.

Start Monitoring Your pytest Tests

Free to get started. Set up in under 5 minutes.

Get Started

Other Frameworks