Skip to content

Add JUnit report generation support to test runner - #72

Open
swissspidy wants to merge 2 commits into
mainfrom
claude/wordpress-core-testing-automation-yrlybg
Open

Add JUnit report generation support to test runner#72
swissspidy wants to merge 2 commits into
mainfrom
claude/wordpress-core-testing-automation-yrlybg

Conversation

@swissspidy

@swissspidy swissspidy commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary

This change adds support for generating JUnit XML reports from Behat test runs, enabling better integration with CI/CD systems and test result tracking.

Key Changes

  • Added $WP_CLI_TEST_JUNIT_DIR environment variable support to optionally write JUnit reports to a specified directory
  • Reports are generated in addition to the standard progress output
  • Failed scenarios are automatically rerun, with rerun reports written to a rerun subdirectory to distinguish between flaky and truly failing tests
  • Updated documentation in README.md with usage examples and explanation of the report structure

Implementation Details

  • When $WP_CLI_TEST_JUNIT_DIR is set, the script creates the directory structure (including rerun subdirectory) and constructs appropriate Behat format arguments
  • The --format junit --out std --out <dir> pattern is used to maintain progress output on stdout while writing JUnit XML to the specified directory
  • Rerun reports use a separate subdirectory to avoid overwriting the full test report, allowing users to identify flaky tests by comparing which scenarios appear in the initial report but not in the rerun report
  • The implementation gracefully handles the case where the environment variable is not set, maintaining backward compatibility

https://claude.ai/code/session_01CE81GsxUY597AdaMP1NXzk

Summary by CodeRabbit

  • New Features

    • Added optional JUnit report generation for test runs.
    • Added separate storage for reports generated during failed-scenario reruns.
    • Displays the configured report destination when enabled.
    • Prevents stale reports from previous runs and omits rerun reports when all scenarios pass.
  • Documentation

    • Documented JUnit report configuration, naming, locations, usage, and flaky scenario reporting.

The progress output prints one character per step, which says how many
scenarios failed but not which ones. That makes it hard to compare two
runs, such as a run against a WordPress build under test and a run
against the build it is based on, in order to tell which failures the
change under test actually caused.

Setting `WP_CLI_TEST_JUNIT_DIR` now additionally writes JUnit reports to
the given directory. Those name every scenario along with the file and
line it is defined on.

Failed scenarios are run a second time. Reports of that rerun go to a
`rerun` subdirectory, as they only cover the scenarios that failed the
first time and would otherwise overwrite the full report of the package.
Keeping both makes it possible to tell a flaky scenario, which fails
once and then passes, from one that consistently fails.

The progress output is unchanged, and nothing happens unless the
environment variable is set.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CE81GsxUY597AdaMP1NXzk
Copilot AI lite review requested due to automatic review settings August 9, 2026 16:02
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a0280bf4-d0b9-45f6-a197-f721df1faf95

📥 Commits

Reviewing files that changed from the base of the PR and between 8967528 and 2762685.

📒 Files selected for processing (2)
  • README.md
  • bin/test-source
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • bin/test-source

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The test script now supports optional JUnit reports for initial runs and failed-scenario reruns. It removes stale reports, creates separate report locations, and logs the configured destination. The README documents configuration, naming, storage, and flaky-scenario reporting.

Changes

JUnit reporting

Layer / File(s) Summary
Configure JUnit report output
bin/test-source, README.md
The script configures the optional JUnit output directory, removes stale reports, creates the rerun directory, and assigns report paths. The README documents the configuration and report behavior.
Pass reports to Behat
bin/test-source
The initial Behat run and failed-scenario rerun use their corresponding JUnit argument arrays.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 27626

The change adds optional JUnit report output while preserving existing test-runner behavior when the setting is absent; no actionable merge-blocking risk remains beyond normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding JUnit report generation support to the test runner.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/wordpress-core-testing-automation-yrlybg

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional JUnit XML report generation for Behat-based test runs to improve CI/CD integration and result tracking, while keeping existing progress output behavior.

Changes:

  • Documented a new WP_CLI_TEST_JUNIT_DIR environment variable and the report/rerun directory structure in README.md.
  • Updated bin/test-source to emit JUnit reports (including rerun reports under a rerun/ subdirectory) when WP_CLI_TEST_JUNIT_DIR is set.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
README.md Adds usage docs and explains how initial vs rerun JUnit reports are organized.
bin/test-source Adds conditional Behat CLI arguments and directory creation to generate JUnit XML reports (plus rerun reports).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bin/test-source`:
- Around line 55-61: Update the JUnit setup around JUNIT_ARGS and
JUNIT_RERUN_ARGS to remove stale XML reports owned by this runner before the
test loop begins, including prior files under the rerun directory. Preserve the
existing output paths and avoid deleting unrelated files in
WP_CLI_TEST_JUNIT_DIR.
- Around line 17-21: The flaky-detection documentation must use testcase status
transitions: in bin/test-source lines 17-21, rewrite the shell comments to
compare matching testcase statuses, identifying failed-then-passed as flaky; in
README.md line 49, document failed-to-passed as flaky and failed-to-failed as
consistently failing.

In `@README.md`:
- Line 44: Update the report-path code block in README.md to declare the text
language by changing its opening fence to ```text, while preserving the listed
paths and closing fence.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e6e97d94-1ff3-4a58-9fa6-e43cc4cf342c

📥 Commits

Reviewing files that changed from the base of the PR and between 0554fab and 8967528.

📒 Files selected for processing (2)
  • README.md
  • bin/test-source

Comment thread bin/test-source Outdated
Comment thread bin/test-source
Comment thread README.md Outdated
The rerun report holds a result for every scenario it ran, including the
ones that passed the second time, rather than omitting them as the
documentation claimed. A flaky scenario is therefore one reported as
failed in the report of the package and as passed in the rerun report,
not one that is missing from the latter.

Reports of an earlier run are now removed before the tests start. A
package that passes produces no rerun report at all, so a report left
behind by an earlier run would have been read as belonging to the
current one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CE81GsxUY597AdaMP1NXzk
@swissspidy

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants