pytest

A guide for generating Trunk-compatible test reports for Pytest

1. Generate JUnit

Add the --junit-xml argument to your pytest command:

pytest --junit-xml=junit.xml 

2. Output Location

The test results JUnit report will be written to the location specified by the --junit-xml argument. In the example above, it would be at ./junit.xml.

Disable Retries

You need to disable automatic retries if you previously enabled them. Retries compromise the accurate detection of flaky tests.

Omit the --lf or --ff options if you've previously configured your CI with these options to disable retries.

Next Step

JUnit files generated with pytest are compatible with Trunk Flaky Tests. See CI Providers for a guide on how to upload test results to Trunk.

Last updated