Skip to the guide
All guides

Testing strategy

Plan, write, debug or review WordPress tests, and check that a passing run proves something.

app WordPress DevKit 2.0.3checked reading 5 minutes

On this page

When to use it

Use this skill to choose the right test layer: unit, WordPress integration, REST or AJAX, WooCommerce HPOS, or Playwright in the browser. It also helps you prove that a regression test fails before the fix, repair flaky or order-dependent suites, and find CI runs that hide failures through lost exit codes or skipped tests. It covers PHPUnit, wp-env and browser test strategy.

Use it when the question is "would a test have caught this?".

What it hands off

The skill decides what to test, at which layer, how to isolate it and whether the run proves anything. Whether the code itself is correct belongs to the owner skill:

  • wp-devkit-security-review, wp-devkit-woocommerce-dev, wp-devkit-rest-api-development, wp-devkit-block-development and wp-devkit-accessibility-review check domain correctness.
  • wp-devkit-phpstan-review covers static typing.
  • wp-devkit-ci-cd-and-release-engineering covers pipeline design.

Run a review in Claude

With the plugin loaded, start a read-only review of one bounded target:

Text
/wp-devkit:test-review <target-path>

The shorter /wp-devkit:test asks for a quick scan instead.

Run a review in Codex, ChatGPT or Antigravity

Name the installed skill and keep the request small. Replace the target with your own files or journey.

Text
$wp-devkit-test-strategy
Review the target without editing files.
Read the project instructions and the skill's engineering contract first.
Separate confirmed findings from candidates and state the evidence and checks you could not run.

The engineering contract is the set of rules every DevKit skill follows. It covers how findings are rated and what counts as evidence.

How a review works

  1. The agent states the behavior you can observe and the failure the regression test must tell apart from success. It finds the real test runner and how a failure reaches the CI exit status.
  2. It picks the cheapest layer that still contains the failing boundary: a pure unit test, a WordPress integration test (hooks, capabilities, storage, REST, AJAX, cron, HTTP), a browser journey or a manual check. A mock that replaces the failing boundary proves nothing about that boundary.
  3. It defines controls. These are a positive case, a denied, invalid, empty or failed-dependency case, and repeat, concurrency or migration cases when the code promises them. Tests should assert stored state and side effects, not only the response.
  4. It checks isolation. Tests need their own data and a reset of globals, the current user, options, transients, cron, the object cache, files and multisite state. They must not depend on order or on the clock.
  5. It checks reliability. There should be no arbitrary sleeps, silent retries or silent skips. .only must be blocked in CI, exit codes must pass through, skipped tests must be listed, and no flag should be able to turn off a required check.
  6. It reports the suitable layer, the regression that fails before the fix, the controls, the runner and versions, and what stays uncovered.

Reference files

The agent starts with the workbook and loads the others only when the task needs them:

  • test-strategy-workbook.md is read first. It gives decision rules, false positives and the finding format.
  • test-layers-and-setup.md is used to choose a layer and set up PHPUnit and the WordPress test suite. It covers wp-env, the version matrix, base classes and isolation rules.
  • wordpress-test-recipes.md is used for test patterns with code for REST, AJAX, capabilities, HTTP, cron, mail, multisite and block serialization.
  • woocommerce-and-data-tests.md is used for the HPOS storage matrix, orders, webhooks, Action Scheduler, migrations, large data sets and cache behavior.
  • browser-and-e2e-tests.md is used for Playwright and wp-env journeys. It covers WordPress e2e utilities, deterministic runs, traces, and visual and accessibility checks.
  • ci-and-evidence.md is used for exit propagation, fail-on flags, flake policy, matrices, artifacts, what coverage means, and baseline and snapshot policy.

What you get back

The report opens with the verdict and scope: the behaviors reviewed, the layers present, and the runner and versions found. Each confirmed gap gives:

  • The behavior, with the file and line.
  • Why the current tests would still pass while it is broken, for example a mocked boundary, a missing negative case, shared state or a swallowed exit code.
  • The impact and the confidence.
  • The proposed regression test: its layer, fixture, steps and assertions on stored state.
  • How to prove that it fails first.

Confirmed gaps, candidates that need a run, and cases with insufficient evidence are listed separately. An implementation also lists the files changed, the commands with exit codes, the before and after results, the checks that were skipped or unavailable, and the risk that remains.

Note

Reviews are read-only. A clean review covers the inspected scope and is not a certification. Ask for implementation as a separate, bounded task with a regression check.

Where to go next

Use review to fix for a bounded implementation and Doctor and reports for environment and evidence tooling.