Backend Development 5 min read

Key Changes and New Features in PHPUnit 10

PHPUnit 10, requiring PHP 8.1+, introduces a new event system, clearer test result classifications, PHP 8 attribute metadata support, and updated code‑coverage tools, while providing PHAR and Composer installation methods, representing a major modernization of the PHP testing framework.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
Key Changes and New Features in PHPUnit 10

PHPUnit is a lightweight PHP testing framework. It is a full port of the JUnit3 series for PHP 5 and a member of the xUnit testing framework family (all based on the design of pattern pioneer Kent Beck).

PHPUnit 10 has been released, the most significant version in the project's history. This version is to PHPUnit what PHP 7 is to PHP: a massive cleanup, refactoring and modernization that lays the foundation for future development.

Note: PHPUnit 10 requires PHP 8.1 or higher. Also, PHPDBG and Xdebug 2 are no longer supported sources for code‑coverage information; PCOV or Xdebug 3 must be used to collect, process, and report coverage data.

Specifically, PHPUnit 10 adds new features, modifies and removes existing ones, and fixes bugs.

Major changes in PHPUnit 10

Event System

Previous versions provided the TestListener and TestHook interfaces for extending the PHPUnit test runner, both of which had serious drawbacks. PHPUnit 10 replaces these interfaces with an event system: (almost) everything is now an event, and all console and log output is based on events.

Test Results and Test Issues

PHPUnit 10 introduces a clear distinction between test results (error, failure, incomplete, skipped, or passed) and test issues (considered risky, trigger warnings, etc.).

The error handler no longer converts E_USER_WARNING , E_USER_NOTICE , E_USER_DEPRECATED , etc., into exceptions. For example, when E_USER_NOTICE is triggered, the test is no longer aborted.

By default, the test runner does not display detailed information about deprecations, notices, or warnings. To show these details, use the CLI options --display-deprecations , --display-notices , and --display-warnings (or the corresponding XML configuration).

Metadata

PHPUnit 10 introduces support for PHP 8 attributes to add metadata to test classes, test methods, and code units. Traditional annotations in comments are still supported, allowing metadata to be attached via modern attributes.

Download Methods

This PHAR archive contains everything needed to run PHPUnit.

➜ wget -O phpunit https://phar.phpunit.de/phpunit-10.phar

➜ chmod +x phpunit

➜ ./phpunit --version
PHPUnit 10.0.0 by Sebastian Bergmann and contributors.

Or install PHPUnit and its dependencies via Composer.

➜ composer require --dev phpunit/phpunit ^10

➜ ./vendor/bin/phpunit --version
PHPUnit 10.0.0 by Sebastian Bergmann and contributors.

Found this article helpful? Like and share to show your support!

backendtestingPHPphpunitCodeCoverageUnitTesting
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.