Sign inSign up free

818. Summarise JUnit Reports in the Job Log

medium 20 XP ~12 minHands-on lab

The test jobs of storefront write JUnit XML reports into reports/ (sub-folders included). Nobody reads them, so the team wants a short summary at the end of the job log.

Task

Create the executable script /home/student/repos/storefront/scripts/junit-summary.sh DIR that reads every *.xml file under DIR (at any depth) and prints:

tests=7 passed=4 failed=2 errors=1 skipped=0
FAIL api.UserTest.test_delete
FAIL smoke
ERROR api.OrderTest.test_refund
  • Count the <testcase> elements themselves. The tests=/failures= attributes on <testsuite> are often wrong: ignore them.
  • A test case is failed when it has a <failure> child, an error with an <error> child, skipped with a <skipped> child, otherwise passed.
  • After the summary line, one line per failed test (FAIL ) and then per errored test (ERROR ), each group sorted. A test is named CLASSNAME.NAME, or just NAME when it has no classname. Names can contain spaces and XML entities (&amp; is &).
  • Exit 1 if any test failed or errored, 0 otherwise, and 2 (with a message on stderr) when DIR contains no .xml file.

Python 3 is installed. Try it on /home/student/repos/storefront/reports.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of CI/CD Pipelines in Practice. Next step: A Makefile That Lies About Being Up to Date

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.