Back to lessons

Hosting Operations

Summarize Test Counts from Reports

You need to know whether one test failed, many tests failed, or the whole suite crashed.

Command

grep -RhoE 'tests="[0-9]+"|failures="[0-9]+"|errors="[0-9]+"|skipped="[0-9]+"' artifacts/test/*.xml | sort | uniq -c

What changed

Nothing changes. The shell prints repeated test count attributes.

Danger

safe

When to use it

Use before diving into individual failures to understand test-suite scope.

When not to use it

Do not use this for exact aggregation across nested XML suites without a real parser.

Undo or recovery

No undo needed because this command is read-only.

Expected output

Counts of test, failure, error, and skipped attributes.

demo script

Disposable terminal steps

  1. cd /lab/ci-artifacts && grep -RhoE 'tests="[0-9]+"|failures="[0-9]+"|errors="[0-9]+"|skipped="[0-9]+"' artifacts/test/*.xml
  2. cd /lab/ci-artifacts && grep -RhoE 'tests="[0-9]+"|failures="[0-9]+"|errors="[0-9]+"|skipped="[0-9]+"' artifacts/test/*.xml | sort | uniq -c
  3. cd /lab/ci-artifacts && sed -n '1,20p' artifacts/test/junit.xml

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ cd /lab/ci-artifacts && grep -RhoE 'tests="[0-9]+"|failures="[0-9]+"|errors="[0-9]+"|skipped="[0-9]+"' artifacts/test/*.xml
tests="4"
failures="1"
errors="0"
skipped="1"
::exit-code::0
$ cd /lab/ci-artifacts && grep -RhoE 'tests="[0-9]+"|failures="[0-9]+"|errors="[0-9]+"|skipped="[0-9]+"' artifacts/test/*.xml | sort | uniq -c
      1 errors="0"
      1 failures="1"
      1 skipped="1"
      1 tests="4"
::exit-code::0
$ cd /lab/ci-artifacts && sed -n '1,20p' artifacts/test/junit.xml

  
  
    AssertionError
  
  
  

::exit-code::0

YouTube Short

Measure the test failure.

Before reading stack traces, check whether CI lost one test, many tests, or the entire suite.

LinkedIn hook

Before debugging a test failure, measure the blast radius.

Question: Do you check test failure counts before reading stack traces?

experiments

A/B tests to run

Metric: short_save_rate

A: Before debugging a test failure, measure the blast radius.

B: Count CI test failures before reading traces.