pest icon indicating copy to clipboard operation
pest copied to clipboard

[2.x] Skipping tests based on group parameter

Open emtudo opened this issue 2 years ago • 2 comments

This PR brings the possibility to skip or run tests based on stipulated groups via the command line using using the --groups= parameter.

Motivation

I would like my tests to reach the API and endpoints during ONLY deployment. This could be achieved with phpunit.xml or with aliases or makefile, but this would need external configuration by my other team members. Also, I would like to avoid passing commands every time I run tests.

Usage

The test below will be skipped unless the group is explicitly called using the --groups= parameter.

Runs the test: ./vendor/bin/pest --group=group1 Skips the test: ./vendor/bin/pest

it('runs this test when group is called', function () {
    expect(true)->toBeTrue();
})
    ->group('group1') // it is not necessary
    ->skipUnlessGroup('group1');

emtudo avatar Aug 09 '22 12:08 emtudo

Lgtm

fabio-ivona avatar Aug 10 '22 10:08 fabio-ivona

I had to make an adjustment because it didn't work in parallel, since the behavior of ArgvInput in parallel is different.

emtudo avatar Aug 10 '22 23:08 emtudo

No plans for this for now.

nunomaduro avatar Sep 18 '22 12:09 nunomaduro