Skip to content

fix: compare JUnit testcases in nested suites under a root <testsuite> instead of silently dropping them

Choose a tag to compare

@noteflowai noteflowai released this 17 Nov 13:36
· 6 commits to main since this release
5060961

'evalarc diff' and load_results now read testcases inside nested elements when the JUnit document root is a single . Before this fix, only the root suite's direct testcases were read, and nested ones were dropped without a message. Nested testcases now go through the normal diff and appear in diff.json, summary.md, index.html and the 'Why the gate failed' section. A nested check that regresses, is removed or becomes unassessed makes the command exit 1. A case ID is the classname if present. Otherwise it is the name of the suite that directly contains the testcase, followed by '::' and the testcase name. identity.suites lists every suite visited, nested ones included. An unnamed nested testcase raises the existing ValueError, which names its position and its suite, and the CLI exits 2. Files with a root and flat files are parsed as before. The English and zh-CN CI gate docs each describe the nested-suite rule. Measured results, all executed by the controller (the author ran nothing): the new acceptance test, run in its pre-fix acceptance check, had 4 of 5 tests fail. The failures covered the nested case load, the regression, the removal and the unnamed-testcase error, and they show the defect. On commit 2f612e1, the controller ran the new acceptance test, the full pytest suite, ruff check, ruff format --check, scripts/build_site.py and scripts/check_site.cjs. All exited 0.

Use it

Prerequisites: Python, a POSIX shell, and evalarc installed from a release or checkout that contains commit 2f612e1 (for example, run pip install . in that checkout). The two XML files below are synthetic and were written by hand for this example.

cat > baseline.xml <<'EOF'

EOF
cat > current.xml <<'EOF'

EOF
evalarc diff baseline.xml current.xml --output junit-diff
echo "exit code: $?"

Expected result: exit code 1. A 'regressed' change for inner::b (baseline status passed) appears in junit-diff/diff.json and under 'Why the gate failed' in junit-diff/summary.md. Before this fix, the same inputs reported no change for inner::b, because the nested testcase was never read. In GitHub Actions, add --markdown "$GITHUB_STEP_SUMMARY" to append the summary to the job page. To rerun the acceptance tests from a checkout: python -m pytest -q tests/test_feature_1513446e184d.py

Scope and upgrade

This change is limited to the JUnit parser in _junit, reached through the existing 'evalarc diff' command and load_results. There is no new flag, format, output field or change kind, and the gate rules, exit codes and output layout are unchanged. Testcases placed directly under outside any suite are still not read. Properties and system-out are still ignored. The acceptance tests use small synthetic XML because no real export with nested suites was supplied. Passing tests show the behavior only for those synthetic cases and the existing suite. Which test runners or JUnit schemas write nested suites under a root is unverified. No user report of this defect exists. This change has no UI. The controller's scripts/build_site.py and scripts/check_site.cjs run passed. That run included the existing showcase browser checks at 1440, 390 and 320 px widths, covering keyboard, link, download and offline behavior. Those checks cover existing showcase pages and do not test this parser change, and no visual review of index.html output for nested-suite inputs was done. All checks were executed by the controller. The author had no tools and did not run or observe them directly.

Install a release that contains commit 2f612e1. Result files are re-parsed on every diff, so no data migration is needed. Results for files and flat files do not change. A gate on files with nested suites under a root may now fail on checks it ignored before. This is the intended correction. Review those findings, or commit a new baseline in a reviewed change. To roll back, pin the previous evalarc version. Rolling back brings back the silent dropping of nested testcases. Input files and earlier output folders are never modified.

Verification

  • Source: #99
  • Version: 0.23.3
  • Verified source commit: 5060961438098d52c939ef13f0cf624cf9fab83b
  • Behavioral acceptance and the repository's release checks passed.

Authored and reviewed with agent assistance; no human review is claimed.