You can extend PHPUnit by creating and using abstract test classes and traits - or by using PHPUnit's event system. As one of the contributors to PHPUnit's new event system, I will give you an overview of the iterations of PHPUnit's event systems, show how you can migrate from any of the previous event systems to PHPUnit's new event system, and share insights on components and the events in the new event system of PHPUnit.
Migrating an extension from the test listener event system to the hooks event system
Here is a https://github.com/johnkary/phpunit-speedtrap/pull/83, migrating johnkary/phpunit-speedtrap from the test listener event system to the hooks event system.
However, the hooks event system also has at least one disadvantage compared to the test listener event system.