try
$this->withoutExceptionHandling();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Say I have a test that fails like this:
Expected status code 201 but received 422.
Failed asserting that 201 is identical to 422.
vendor/laravel/framework/src/Illuminate/Testing/TestResponse.php:186
tests/Unit/ProductTest.php:57
That tells me where it failed, but not why. In this example it's a validation failure, which could be caused by any of my rules, but I can't tell which from the information provided, yet I know that the response contains that info. PHPUnit aggressively suppresses output even during test failures (even killing dd output), so it's unnecessarily difficult to get more feedback on why something failed. As a workaround I'm forced to add manual logging calls to my actual code to dump response data so that I can see the actual error responses, which negates a lot of the point of having automated tests.
How can I get PHPUnit (or some aspect of my test setup) to produce more verbose output on failure?
Please or to participate in this conversation.