Skip to content
Advertisement

Run only one unit test from a test suite in laravel

Using phpunit command Laravel will run all unit tests in our project. How to run one or specific Unit Tests in Laravel 5.1?

I just want to run testFindToken from my test suite.

JavaScript

Advertisement

Answer

Use this command to run a specific test from your test suite.

JavaScript

If you want to be more specific about your file then pass the file path as a second argument

JavaScript

Example:

JavaScript

Note:

If you have a function named testSave and another function named testSaveAndDrop and you pass testSave to the --filter like so

JavaScript

it will also run testSaveAndDrop and any other function that starts with testSave*

it is basically a sub-string match. If you want to exclude all other methods then use $ end of string token like so

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement