Drupal 11 & PHPUnit 10+: A Developer’s Migration Playbook
With the release of Drupal 11 comes a major upgrade: PHPUnit 10+. In his migration playbook, Alexander Shabanov outlines a four‑step pathway to adapt your existing test suites to be compatible with the stricter syntax and API changes of PHPUnit 10 while keeping backward compatibility for Drupal 10.
Shabanov begins by advising developers to establish a clean baseline in Drupal 10, then leverage Rector to automate much of the refactoring—converting annotations to attributes, updating assertions, and removing deprecated methods. He then tackles the trickier parts: enforcing static data providers, replacing removed workflows like withConsecutive() with callback logic, and restructuring tests that previously relied on instance context.
To help modules continue to support both Drupal 10 and 11, the playbook recommends using PhpunitCompatibilityTrait, which microscopically abstracts between the two PHPUnit versions. The end goal: cleaner tests, reduced manual effort, and more robust, future-proof testing infrastructure across Drupal versions.

