How to get a JUnit XML file
Most runners write JUnit XML with one flag or one reporter. These are the commands from each tool's own documentation:
| Runner | Command or setting | Where the file goes |
|---|---|---|
| pytest | pytest --junit-xml=report.xml | The path you give |
| Playwright | npx playwright test --reporter=junit with PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml, or reporter: [['junit', { outputFile: 'results.xml' }]] in the config | The output file you set |
| Jest | npm install --save-dev jest-junit, then jest --ci --reporters=default --reporters=jest-junit | junit.xml in the working directory, unless JEST_JUNIT_OUTPUT_DIR or JEST_JUNIT_OUTPUT_NAME says otherwise |
| Go | gotestsum --junitfile junit.xml | The path you give |
| Maven Surefire | Runs by default in mvn test | One TEST-<class>.xml per test class in target/surefire-reports |
If your runner isn't listed, search its docs for "JUnit reporter": the format is the common exchange format for CI test results, and CircleCI, for one, requires it to split tests by timing.
What the viewer reads
A JUnit file is a <testsuites> element (optional) holding <testsuite> elements, each with <testcase> children. A test case with a <failure> child failed an assertion, one with <error> broke in another way (an exception, a setup crash), and one with <skipped> did not run. A test case with none of them passed.
When the file looks wrong
JUnit XML has no single official schema, so writers differ; the JUnit XML format guide shows what each runner writes. pytest, for example, can add a <properties> block to a test case with record_property, which its documentation warns breaks validation against the latest JUnit XML schema. Readers that only know one dialect then skip tests or reject the file. If a dashboard shows numbers that disagree with this viewer, run the file through the JUnit XML validator: it flags counts that don't match the test cases, times that aren't numbers and duplicate test names, with the line of each.
Sources
Testland for teams
In developmentAutomated test reports, manual test runs and regression tracking in one workspace. A separate product, built on the same skills.
One email when it opens, nothing else. Privacy policy