# JUnit Run Compare

> Compare JUnit-XML reports of two runs: one row per test that newly fails, went missing, flakes, got skipped or slower, with file:line; exit 1 for CI on new failures; names every case it could not read, and never passes on a run it could not read.

JUnit Run Compare is a paid AI agent skill on Agensi by Hale Sinclair, in Testing & Debugging. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $5 (one-time purchase)
- Creator: [Hale Sinclair](https://www.agensi.io/creators/hale-sinclair)
- Category: [Testing & Debugging](https://www.agensi.io/skills/testing-debugging)
- Version: 1.0
- Last updated: 2026-12-01
- Security: scan passed (2026-12-01); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/junit-run-compare
- Tags: testing, devops, code-review, junit, junit-xml, test-results, ci, flaky-tests

## About this skill

### The problem
A green CI run can hide a lot: a test that was not collected, a failure that became a skip, a test that fails one run in three. A red run often fails for reasons that were there before the pull request. Comparing two JUnit-XML reports by eye is slow, and a comparison that skips what it cannot read can say all is well when it read almost nothing.

### What it does
Your agent runs one standard-library Python script over the JUnit-XML reports of two runs (base and head) and explains the result. The files of one run are its shards and are read together; `--run` adds a rerun of the same code to a side. A test is the same test only when its suite path, classname and name are equal, never by likeness. Each test whose status changed, or that still fails or got slower, is one row with the rule, the test, the status on each side and the file and line of its test case:
- **FAIL**: `newly-fails` (passed, now fails), `new-test-fails` (a new test that fails), `missing` (in base, in no head file).
- **REVIEW**: `flaky` (passed and failed across the reruns of one side, or a Surefire flaky element), `still-fails`, `skipped-now`, `slower` (mean time at least 1.5 times base and at least 0.5 s more; `--slower` sets the ratio).
- **INFO**: `fixed`, `unskipped`, `new`, `new-skipped`.

Exit 0 is PASS, exit 1 is FAIL n, INCOMPLETE or NOTHING COMPARED, exit 2 a usage error; `--json` gives the same result for a CI step. A run that matched no test says NOTHING COMPARED, and names its FAIL rows when it has any. A run with no FAIL row but any file, suite or test case it could not read or compare, any suite whose counts disagree with the cases it holds, or a head that skipped more than half of the matched tests says INCOMPLETE, and the verdict line names every reason: (n of m cases compared; n file(s), run(s), suite(s) or case(s) not read; n suite count(s) disagree; head ran n of m matched cases). With a FAIL row it says FAIL n with the same reasons. It writes only the `--out` file you name.

### What you get that prompt-only skills don't
- **The rules are a table, not memory.** The same reports give the same rows every time; the 11 rules are data the check tests one by one.
- **What was not read is counted and named**, with file and line: a file that is not XML, not JUnit, has a DOCTYPE or declares an encoding it does not read; a case with an element, status or result word the script does not know, no name or a time that is not a number of seconds at least 0; and every file's testcase elements are counted a second time by a bare XML pass, so a case the reader did not reach is NOT READ, never silently dropped.
- **A name written twice in one run is not guessed at.** Copies of one name (Playwright projects, jest-junit's default suite names, retries) are compared only when every copy agrees; otherwise they are NOT COMPARED, with the copies counted per run.
- **Read on real reports, not only on a demo.** 38 real reports, shards and reruns included, were read whole and checked as described below.

### Next to the JUnit skills already listed
- *junit-baseline-delta-review* says it will "Compare JUnit XML reports to identify regressions, recovered tests, and missing cases for PR and release audits." Its page says: "Comparison stops on duplicate test keys. Cannot determine flakiness or edit code." This one also compares, and reports flaky tests (several reruns per side), slower tests (times) and every file or case it could not read.
- *junit-flaky-slow-test-reporter* reads several runs of one commit and ranks flaky and slow tests. This one compares two sides (before and after a change); it does not cluster failure messages.

### Why pay $5 when EnricoMi/publish-unit-test-result-action is free
That GitHub Action does more in its place: it posts results as GitHub check runs and pull-request comments, compares with the results of an earlier commit for you, and reads more formats (JUnit, NUnit, XUnit, TRX, Dart JSON). Use it if you live in GitHub Actions. This skill is for the other cases:
- **Offline, anywhere:** one standard-library Python file that opens no socket and runs no program, on any two sets of reports you have (claim 1).
- **Shards and reruns per side:** a sharded run read as one, several runs of the base and of the head, with a test that passed and failed on one side reported as flaky and the failing run named (claims 4 and 8).
- **file:line on every row**, found in its file on every real report (claim 11).
- **Names what it did not read**, with its place, and then never says PASS (claim 3).

### How it works
- The agent finds the base reports (main's CI artifacts, or a run on the base commit) and the head reports, and runs the script.
- It reads the verdict and the counts first, then each FAIL and REVIEW row, then the NOT READ, COUNTS DISAGREE and NOT COMPARED lists.
- It says which rows the change caused and which were already there, and it does not rerun or edit tests to make a verdict pass.

### What was checked, and how
Every number here is read from the check's own output (`check.out`) when this page is written.
- **321 regression cases** (paths and `--out` over an input, usage and exit codes, BOM, CRLF, UTF-16, single-byte encodings, Shift-JIS and GBK refused, DOCTYPE refused, not XML, not JUnit, the gate and its reasons, every status and result word known, CTest's notrun by its message, Surefire rerun elements, suite counts, the second count, shards, reruns and copies, times), each shown failing on at least one of 187 deliberately broken copies of the script or the rule table.
- **11 rules as a data table**, equal to the script both ways.
- **38 real reports** written by pytest, mocha, ScalaTest, TestNG, PHPUnit, jest-junit 16 and 17, CTest and Playwright (public projects' reports, and runs of our own small projects split into shards and rerun; reduced only where named in inputs/SOURCES.md): 1997 test cases read, none not read. Four re-encodings of each report (152 runs: BOM, CRLF, UTF-16, one line) gave the same rows; 228 one-fact changes each gave exactly one new row of the planted rule; 10 copies with twelve changes at once each gave twelve rows, one per change; every place of 428 rows was found in its file.
- **A second reading** with junitparser, a separate JUnit library, over 262 pairs (the real reports, every planted copy and every rule's example), with the copies rule written from SKILL.md, not from the script: 217 agree; 42 differ only by Surefire flaky elements junitparser does not know and 1 by its rerunFailure example, and 2 by CTest's `status="disabled"` with no skipped element, which junitparser reads as a pass.
- **Real shards:** Playwright and jest-junit runs we split with `--shard`, when the shards are given as one run (all of a side's files together, without --run): a failure on one shard or one browser is never taken for a flaky test, the same code sharded differently on each side passes, and with the project in the test name a webkit-only failure is a FAIL row (regression cases).

### Known limitations
- JUnit-XML only. Tested on real reports from pytest, mocha, ScalaTest, TestNG, PHPUnit, jest-junit 16 and 17, CTest and Playwright (mocha's own xunit reporter; mocha-junit-reporter was not tested; it leaves it.skip tests out of the file but in tests=, so such a run is INCOMPLETE); Surefire's flakyFailure and rerunFailure elements only on small reports written for the tests; Go reports were not tested. Gradle is not supported: it writes some test names with object hash codes that change every run, so each such test shows as one missing and one new row.
- jest-junit writes a test.todo as a test case with no skipped element and leaves it out of the suite's tests= count, so a run with any test.todo is COUNTS DISAGREE and the verdict INCOMPLETE, never PASS: remove the todos (or turn them into test.skip) before comparing.
- PHPUnit 10 and later name the top suite after the absolute path of phpunit.xml: run base and head from the same directory (the same checkout path), or every test shows as missing and new and the verdict is NOTHING COMPARED, never PASS.
- It compares statuses and times, not failure messages: a test failing for a new reason in both runs is one still-fails row.
- A test is its suite path, classname and name, exactly. A name written more than once in one run (copies) is one test only when every copy has the same outcome and each run holds as many; when every head copy fails and no base copy did, it newly fails; otherwise it is NOT COMPARED and the verdict INCOMPLETE. Playwright with several projects writes the project only in a hostname attribute, so every test is copies: set includeProjectInTestName. jest-junit names every suite "undefined" unless its suiteNameTemplate is set to "{filepath}".
- The files of one run are read together as its shards; reruns of the same code are given with --run. A test that failed in one run and passed in another is flaky; a test absent from a run (a rerun of only the failed tests) is judged by the runs that hold it, but a rerun (a run on a side of two runs or more) that holds no test case at all is NOT READ. Reruns given as shards of one run make copies: NOT COMPARED when they differ.
- Shards given with --run are read as reruns: a test that fails on one shard or one project then reads as flaky (a REVIEW row) and the verdict can be PASS. A CI job per --shard or per Playwright --project is a shard: give all of a side's files as one run.
- A runner that writes a retried test again under one name (TestNG, gotestsum --rerun-fails, Gradle retries) makes copies: a failure then a pass on retry is NOT COMPARED, not flaky. pytest-rerunfailures writes a failed attempt as an extra test case, so that suite holds more cases than its tests= says: COUNTS DISAGREE, INCOMPLETE.
- slower compares mean times; one noisy run can make or hide a slower row. A time with a decimal comma is read, but not a comma followed by three digits (a decimal comma or a thousand separator?); that, a time that is not a number of seconds, or a negative one is NOT READ.
- A renamed or moved test or suite shows as one missing and one new row.
- A report written on one line (pytest does) gives line 1 as the place of every case; the test name finds it.
- REVIEW rows do not fail the verdict, but a head run that skipped more than half of the matched tests is INCOMPLETE (head ran n of m matched cases), not PASS. CTest's notrun is a skip only when every skipped message it holds is a SKIP_RETURN_CODE or SKIP_REGULAR_EXPRESSION_MATCHED message; any other notrun (the test program was not found) is a failure.
- A file with a DOCTYPE, or declared in an encoding other than UTF-8, UTF-16 and the ASCII-based single-byte code pages (Shift-JIS, GBK, UTF-32, an unknown name), is NOT READ: convert it to UTF-8.
- It reads reports, not code or commits: it cannot say why a test failed or which change caused it.
- Names, paths and quoted words in the text report, the --out file and stderr pass one escape: a line break, CR, ESC, a Unicode line separator or a bidi control prints as \xNN or \uNNNN, a backslash as \\, so a test name cannot forge a row or the verdict line. The exact names are in --json.

## Requires

- Python

No accounts, API keys, database connection or services. Python 3.9+ on the machine.

## Known limitations

JUnit-XML only. Tested on real reports from pytest, mocha, ScalaTest, TestNG, PHPUnit, jest-junit 16 and 17, CTest and Playwright (mocha's own xunit reporter; mocha-junit-reporter was not tested; it leaves it.skip tests out of the file but in tests=, so such a run is INCOMPLETE); Go reports were not tested. Gradle is not supported: it writes some test names with object hash codes that change every run, so each such test shows as one missing and one new row. jest-junit writes a test.todo as a test case with no skipped element and leaves it out of the suite's tests= count, so a run with any test.todo is COUNTS DISAGREE and the verdict INCOMPLETE, never PASS: remove the todos before comparing. PHPUnit 10 and later name the top suite after the absolute path of phpunit.xml: run base and head from the same directory (the same checkout path), or every test shows as missing and new and the verdict is NOTHING COMPARED, never PASS. It compares statuses and times, not failure messages: a test failing for a new reason in both runs is one still-fails row. Playwright with several projects writes the project only in a hostname attribute, so every test is copies: set includeProjectInTestName. jest-junit names every suite "undefined" unless its suiteNameTemplate is set to "{filepath}". Shards given with --run are read as reruns: a test that fails on one shard or one project then reads as flaky (a REVIEW row) and the verdict can be PASS. A runner that writes a retried test again under one name (TestNG, gotestsum --rerun-fails, Gradle retries) makes copies: a failure then a pass on retry is NOT COMPARED, not flaky. pytest-rerunfailures writes a failed attempt as an extra test case, so that suite holds more cases than its tests= says: COUNTS DISAGREE, INCOMPLETE. It reads reports, not code or commits: it cannot say why a test failed or which change caused it. The full list is under Known limitations in the description.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the JUnit Run Compare skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### Does it run my tests?

No. It reads the JUnit-XML files your CI already wrote, opens no socket and runs no program. It needs a base report: a CI artifact from main, or a run on the base commit.

### What does PASS mean?

That no rule of severity FAIL fired, that every file, suite and test case was read, every suite's counts agree with its cases, every test was compared, and HEAD ran (did not skip) at least half of the matched tests. A word the script does not know is NOT READ, never a pass. It is not a promise the code is right: REVIEW rows (flaky, still failing, skipped now, slower) still need a person.

### Can I give it several reruns, or a sharded run?

Yes. All the files of one run (shards, one file per test file) go together; each rerun of the same code is given after --run: a test that passed in one run and failed in another is flaky on that side. A name written twice in one run is compared only when its copies agree, else it is NOT COMPARED and the verdict INCOMPLETE, so give each test a unique name (with Playwright, includeProjectInTestName).

### My runner is not in the tested list. Will it work?

If it writes JUnit XML, probably; but only the runners named under Known limitations were tested on real reports. Anything it cannot read is listed as NOT READ with its file and line, and the verdict is then INCOMPLETE, not PASS.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
