Automation Testing · Professional Practice

Test Reporting

A failed test is only useful if someone can quickly see what failed and why. Good reports make that possible.

Advanced 5 min Lesson 19 of 24
Before you start:Playwright Test Runner
0/24 in Automation Testing
On this page · 5 min · Advanced

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#

YAML.github/workflows/e2e.yml (steps) Illustrative
      - 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
Expected output
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#

  1. Tests run against staging.
  2. The HTML report is uploaded even when tests fail.
  3. JUnit XML is turned into a check-run summary.
  4. 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#

Uploading reports only on success

Use if: !cancelled() so failures — when you need reports most — are kept.

Recording video for every test

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
TypeScript Illustrative
use: { screenshot: 'only-on-failure', video: 'retain-on-failure', trace: 'on-first-retry' }

Mini quiz#

Test Reporting quizMultiple choice Question 1 of 1

Which format do most CI systems read to display test results?

Score so far: 0/0

Want more? Practise all Automation Testing MCQs · Automation Testing interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.