PHPUnit 13.5 shipped on 4 December 2026, followed by 13.5.1 the same day. It isn’t a flashy release, but it changes a lot of what you see when a test run goes wrong. There’s a machine-readable JSON result, a “run receipt” that records how a run ended, a way to print the effective configuration without running anything, and much stricter reporting when a run is stopped, interrupted or times out.

If you run PHPUnit in CI, or let an AI coding agent run your tests, these changes are worth knowing about. Everything below comes from the official PHPUnit 13.5.0 release notes. I tested the commands with PHPUnit 13.5.1 on PHP 8.4.

Installing or upgrading

PHPUnit 13.5 requires PHP 8.4.1 or newer, according to Packagist.

composer require --dev "phpunit/phpunit:^13.5"
vendor/bin/phpunit --version
# PHPUnit 13.5.1 by Sebastian Bergmann and contributors.

For the examples I used a tiny Cart class and a CartTest with two tests, plus this phpunit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
         executionOrder="random"
         cacheDirectory=".phpunit.cache">
  <testsuites>
    <testsuite name="unit">
      <directory>tests</directory>
    </testsuite>
  </testsuites>
  <source>
    <include><directory>src</directory></include>
  </source>
</phpunit>

1. --show-effective-configuration: what will actually run?

Have you ever wondered which bootstrap, extensions or cache directory a run will use, once the XML file, CLI flags and defaults are combined? The new flag prints exactly that, without running any tests:

vendor/bin/phpunit --show-effective-configuration

The output starts with an “Executes” section listing bootstrap scripts, extensions, PHP settings and the number of test files. A “Writes” section shows where history and caches go. After that comes every setting with its resolved value:

Executes:
  Bootstrap scripts:
    - vendor/autoload.php
  Extensions: (none)
  Test files: 1

Writes:
  Test run history: .phpunit.cache/test-run-history

Settings:
  backupGlobals: false
  cacheDirectory: /path/to/project/.phpunit.cache
  ...

This is a quick way to debug “works locally, fails in CI” problems, where an environment-specific flag or config file changes the run.

2. JSON results with --json and --log-json

PHPUnit can now print the result of a run as a JSON document (--json) or write it to a file (--log-json). Here is a trimmed real result:

{
  "schemaVersion": 1,
  "invocation": {
    "version": "13.5.1",
    "php": "8.4.28",
    "arguments": ["--json"],
    "configurationFile": { "path": "phpunit.xml", "sha256": "ee7f..." }
  },
  "outcome": { "status": "completed", "shellExitCode": 0, "duration": 0.001 },
  "tests": {
    "selected": 2, "run": 2, "passed": 2, "failed": 0,
    "errored": 0, "skipped": 0, "incomplete": 0, "risky": 0,
    "assertions": 2
  },
  "observations": []
}

When a test fails, each problem appears in observations with its kind, test ID, file, line, message and trace. That’s much easier to parse than scraping text output. A short script can post a summary to a pull request:

<?php
$result = json_decode(shell_exec('vendor/bin/phpunit --json'), true);

printf(
    "%s: %d run, %d failed, %d errored\n",
    $result['outcome']['status'],
    $result['tests']['run'],
    $result['tests']['failed'],
    $result['tests']['errored'],
);

foreach ($result['observations'] as $o) {
    printf("- %s in %s:%d – %s\n", $o['kind'], $o['file'], $o['line'], $o['message']);
}

Use --details-limit <n> to cap the length of messages, diffs and stack traces in JSON and compact output. This helps keep logs, or an AI agent’s context window, small.

3. Compact output now ends with a receipt

The --compact output now ends with a run receipt: the arguments, working directory, config file hash, bootstrap, start and end times, final status and exit code. Here is real output:

OK (2 tests, 2 assertions)

--- RECEIPT
Arguments: --compact
Working directory: /path/to/project
Configuration: phpunit.xml (SHA-256: ee7fbcd4...)
Bootstrap: vendor/autoload.php
Duration: 0.001 seconds
Shell exit code: 0
Tests: 2 run, 2 assertions

Compact output also indents lines under each record header by two spaces, and prints file paths relative to the working directory. Long stack traces become much easier to read.

4. “OK” no longer hides a run that was cut short

This is the change most likely to affect CI. Before 13.5, a run stopped early by --stop-on-failure or a signal could still say “OK” if no test had failed yet. Now:

  • The default output says STOPPED! when a --stop-on-* option ended the run, INTERRUPTED! for a signal and TIME LIMIT EXCEEDED! when --timeout was exceeded. It also names the option that stopped the run.
  • A run interrupted by SIGINT exits with code 130.
  • An exceeded run time limit is reported with exit code 124.
  • A run that can’t start, for example because the cache directory isn’t writable or the bootstrap file fails to load, prints a NOT STARTED record and exits with code 2 before loading tests.

If your CI scripts treat any non-zero exit code as failure, you’re fine. If they grep for “OK”, update them to check the exit code, or better, read outcome.status from --json.

5. Reproducible random order with --random-seed

--random-seed <N> is the new name for seeding random test order, and it now seeds PHP’s random number generators whether or not PHPUnit itself needs randomness:

vendor/bin/phpunit --random-seed 1234
# Random Seed:   1234

The old --random-order-seed is deprecated. When I used it, the run reported a PHPUnit deprecation. Update your scripts now. In Open Test Reporting XML logs, phpunit:randomOrderSeed is renamed to phpunit:randomSeed, so update any tooling that reads that attribute.

6. Better timeouts and process isolation

The --timeout option (a limit for the whole run) got much stricter:

  • A run with --timeout refuses to start if the pcntl extension is missing, instead of only checking the limit between tests.
  • Tests in separate processes and PHPT tests are now aborted when the limit is exceeded.
  • Child processes a test started, such as with exec(), are terminated shortly after the limit passes (this needs the posix extension and doesn’t work on Windows).

Also, before-first-test methods like setUpBeforeClass() for classes whose tests all run in separate processes are no longer called in the main runner process.

7. Code coverage improvements

PHPUnit 13.5 pairs with php-code-coverage 14.6:

  • The HTML report shows how many tests cover each line, plus n/p keyboard shortcuts to jump between uncovered code.
  • Multi-line && and || operands and ?-> chains are no longer marked covered when they weren’t executed.
  • The XML report includes branch and path coverage.
  • --gaps-only limits the JSONL coverage report to code that isn’t covered.

Deprecations to fix now

  • --random-order-seed → use --random-seed.
  • Calling markTestSkipped() or markTestIncomplete() in tearDown() or tearDownAfterClass().
  • Loading test runner extensions from PHARs with extensionsDirectory.

Version requirements in #[RequiresPhp], #[RequiresPhpExtension] and #[RequiresPhpunit] are also stricter. Values like 8.5-dev or >=8.3 <8.5 now cause an error. Use a constraint such as ^8.5 or a comparison like >= 8.5.0.

Takeaway

Upgrade with composer require --dev "phpunit/phpunit:^13.5", then switch to --random-seed. Make sure your CI relies on exit codes rather than the word “OK”. For tooling and AI agents, --json plus --details-limit gives you clean, structured results without scraping text output.