Collision PHPUnit Listener With Laravel

Collision PHPUnit Listener With Laravel

Collision is an error reporting tool for PHP command line applications. It ships as a dev dependency for Laravel starting back in Laravel 5.6, but I recently noticed the package’s author mention the PHPUnit adapter:

While collision ships with Laravel, you need to configure the listener if you want to use it with PHPUnit. I thought I’d quickly demonstrate setting it up with Laravel.

Here’s the default PHPUnit experience when you have an exception during a test. You might notice that the first place you want to look is the top of the exception stack, so you have to scroll up to see it:

To get a much better experience, add the Collision listener to your Laravel project’s phpunit.xml file:

<listeners>
    <listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener" />
</listeners>

Now you get a nice clean view of where the exception occurred after the full stack trace:

Boom! Collision provides a much better experience while running PHPUnit tests via the command line!

To learn more about this package, check it out on GitHub at nunomaduro/collision.

Filed in: News
Laravel News Partners

Laravel Jobs

Senior Full-Time Laravel Developer (REMOTE)
Remote, ANYWHERE
Vue School
Senior Laravel Developer
Remote, USA & Canada Only
Givecloud
Backend Software Engineer
Remote, USA Only
CommentSold
Backend Software Engineer (x/f/m)
Remote
Smartbnb
Senior Developer
Remote
Shelterluv

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.