Back to lessons

Hosting Operations

List Failed Tests from JUnit XML

A test log is long, but the JUnit report contains structured failure records that can identify failed test cases quickly.

Command

grep -RIn '

What changed

Nothing changes. grep prints failure and error records from XML reports.

Danger

safe

When to use it

Use when test logs are noisy but XML reports are available.

When not to use it

Do not use simple grep as a full XML parser when exact structured extraction is required.

Undo or recovery

No undo needed because this command is read-only.

Expected output

JUnit XML lines containing failure or error elements.

demo script

Disposable terminal steps

  1. cd /lab/ci-artifacts && find artifacts/test -name '*.xml' -print
  2. cd /lab/ci-artifacts && grep -RIn '
  3. cd /lab/ci-artifacts && sed -n '1,80p' artifacts/test/junit.xml

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ cd /lab/ci-artifacts && find artifacts/test -name '*.xml' -print
artifacts/test/junit.xml
::exit-code::0
$ cd /lab/ci-artifacts && grep -RIn 'AssertionError
::exit-code::0
$ cd /lab/ci-artifacts && sed -n '1,80p' artifacts/test/junit.xml

  
  
    AssertionError
  
  
  

::exit-code::0

YouTube Short

Ask JUnit what failed.

When the test log is a wall of text, check the JUnit XML. Failed cases are already marked.

LinkedIn hook

The XML report already knows which tests failed.

Question: Do you inspect JUnit XML directly when test logs get noisy?

experiments

A/B tests to run

Metric: linkedin_save_rate

A: The XML report already knows which tests failed.

B: Skip the noisy test log. Check JUnit.