Document your app with PHPUnit Testdox output
When you run your application’s test suite (you do have a test suite, right?) with PHPUnit, you will probably be familiar with the following output style:
PHPUnit 9.5.26 by Sebastian Bergmann and contributors.Testing
..............................R.................R.... 65 / 90 ( 72%)
......................... 90 / 90 (100%)Time: 00:05.650, Memory: 155.00 MB
The main advantage of this output format is that it is concise, especially when you have a lot of tests. It quickly gives you an overview of tests that failed, have errors, or are considered risky.
However, the downside is that it’s not immediately clear what each test is actually testing. Each test is simply represented by a .
character and that is all.
There is an alternative that many people do not seem to know about. PHPUnit has an option to change the output format to one that is much more descriptive, and that relies on the information already in your tests to create these descriptions.
Lets say you have a test class such as the following:
<?php
declare(strict_types=1);use PHPUnitFrameworkTestCase;final class CustomerSubscriptionsTest extends…