Test Reporting
A failed test is only useful if someone can quickly see what failed and why. Good reports make that possible.
On this page · 5 min · Advanced
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Advanced
- Updated
- Oct 29, 2026
Related tutorials
Learning objectives#
- Generate HTML and JUnit reports
- Capture evidence on failure
- Publish reports from CI
- Track trends over time
Explanation#
Human-friendly reports (Playwright HTML, Allure) show steps, errors, screenshots, videos and traces.
Machine-readable JUnit XML lets CI systems show test results per pull request.
Capture screenshots, videos and traces only on failure to save time and storage.
Trends (pass rate, duration, flaky tests) show whether the suite is getting healthier.
Code example: Publishing reports in GitHub Actions#
- run: npx playwright test
env: { BASE_URL: https://staging.shop.example }
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 14
- uses: dorny/test-reporter@v1
if: ${{ !cancelled() }}
with:
name: E2E results
path: results/junit.xml
reporter: java-junit
Each run shows a pass/fail summary on the pull request and a downloadable HTML report with traces for failures.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- Tests run against staging.
- The HTML report is uploaded even when tests fail.
- JUnit XML is turned into a check-run summary.
- Reports are kept for 14 days.
Real-world use case#
Developers open the trace of a failed checkout test, see the exact network error and fix it without rerunning anything.
Common mistakes#
Use if: !cancelled() so failures — when you need reports most — are kept.
Expensive. Record on failure or first retry.
Best practices#
- HTML for people, JUnit for CI
- Evidence on failure only
- Upload reports even when tests fail
- Track pass rate and duration
Remember this#
Reports must explain failures fast.
Screenshots/videos/traces on failure.
Upload with if: !cancelled().
Practice exercise#
Your task: Configure Playwright to keep screenshots only for failed tests.
Show solution
use: { screenshot: 'only-on-failure', video: 'retain-on-failure', trace: 'on-first-retry' }
Mini quiz#
Which format do most CI systems read to display test results?
Want more? Practise all Automation Testing MCQs · Automation Testing interview questions
My notes#
Saved in this browser.