C.W.K.
Stream
Lesson 07 of 13 · published

Test Reporting

~11 min · reporting, junit, coverage

Level 0Apprentice
0 XP0/101 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

Stop reading raw logs to find failures

The default test output in CI is a wall of console text. Real test reporting extracts structured data — what passed, what failed, how long each took, where it broke — and surfaces it on the PR or in the run summary.

Two layers

1) Test result formats

  • JUnit XML — universal. pytest --junitxml=report.xml, vitest --reporter=junit, etc.
  • SARIF — for security scanners, surfaces in PR review UI.
  • Cobertura / lcov — coverage formats.

2) Renderers

  • GitHub Step Summary — append markdown to $GITHUB_STEP_SUMMARY from any step. Renders on the run page.
  • PR Comment — third-party actions like EnricoMi/publish-unit-test-result-action post a sticky comment summarizing the test run.
  • Coverage badge — push to Codecov or Coveralls; their actions also comment on PRs.
  • Annotations — emit ::error file=foo.py,line=12::message from a step to make GitHub draw inline annotations on the PR diff.

Code

Step summary + JUnit + annotations·yaml
      - name: Run tests
        id: tests
        run: |
          pytest --junitxml=report.xml --cov=src --cov-report=term-missing | tee out.log

      - name: Append summary
        if: always()
        run: |
          echo '## Test summary' >> $GITHUB_STEP_SUMMARY
          tail -n 20 out.log >> $GITHUB_STEP_SUMMARY

      - name: Publish JUnit on PR
        if: always()
        uses: EnricoMi/publish-unit-test-result-action@v2
        with:
          files: report.xml

External links

Exercise

Take your CI workflow and add a step summary that includes the last 30 lines of test output. Open a recent run and verify the summary renders correctly.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.