Skip to content

feat(reports): add --report-json <file> for machine-readable output#759

Merged
Chemaclass merged 2 commits into
mainfrom
feat/reports-json
Jul 10, 2026
Merged

feat(reports): add --report-json <file> for machine-readable output#759
Chemaclass merged 2 commits into
mainfrom
feat/reports-json

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #741

JUnit XML and HTML already exist, but JSON is the friendliest format for custom tooling (jq, GitHub Action summaries, flaky-test trackers) to consume results without parsing human text or XML.

💡 Changes

  • Add --report-json <file> (and BASHUNIT_REPORT_JSON): writes a summary (counts + duration) plus per-test records (file, name, status, duration, message).
  • Test names and messages are escaped in pure Bash, so the output is always valid JSON with no jq dependency to produce it.
  • Mirrors the existing report writers; like them, per-test rows come from a sequential run and the file stays valid JSON under --parallel.
  • Docs document the schema; CHANGELOG updated.

…741)

Write JSON results (summary counts + per-test records) so scripts, dashboards
and bots can consume bashunit output without parsing human text. Strings are
escaped in pure Bash (no jq dependency). Mirrors the existing report writers;
like them, per-test rows come from a sequential run and the file stays valid
JSON under --parallel.

Closes #741
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 10, 2026
@Chemaclass Chemaclass self-assigned this Jul 10, 2026
)

The unit test compared a multi-line message round-tripped through jq, which
differs by a carriage return on Windows. Assert the quote substring instead;
jq's validity check still proves the newline was escaped correctly.
@Chemaclass Chemaclass merged commit 06441af into main Jul 10, 2026
31 checks passed
@Chemaclass Chemaclass deleted the feat/reports-json branch July 10, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant