Groups Of Tests


Optionally, Pest allows you to assign tests to different groups with the group method. If you have a bunch of particularly slow tests, it might be good to add them all to the same group:

1it('has home', function () {
2 // ..

Of course, you can also assign a test to multiple groups:

1it('has home', function () {
2 // ..
3})->group('integration', 'browser');

Sometimes, you may want to assign an entire file to a group:


Or a specific folder:

1// Pest.php

Finally, you can run the tests of a specific group using the --group option while running Pest on the command-line:

1./vendor/bin/pest --group=integration,browser

You may also exclude specific groups using the --exclude-group option:

1./vendor/bin/pest --exclude-group=api

Note: The uses()->group('integration')->in('Feature') will not put any PHPUnit test class under the integration group. You still need the @group annotation for them. Pest will understand it.

Next section: - Test Dependency →