Skip to content

How to run a single test method in Laravel

I’ve been banging my head the last day or so with a single failing PHPUnit test in a Laravel project I’m working on. Been able to use --filter to narrow down so artisan test would only run tests in the class I’m working on, but wanted to filter it down a bit more.

Turns out it’s really easy.

php artisan test --filter methodName path/to/test/file.php

Let’s say your test method is call testTheThing and it’s in the file tests/Feature/SomeThingTest.php. You’d run the following.

php artisan test --filter testTheThing tests/Feature/SomeThingTest.php

Published inProgramming

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *