Scrutinizer - skip some phpunits

259 views Asked by At

I want to skip some phpunit tests in scrutinizer.

How can I achive the same?

Where do I need to do configuration changes for the same?

2

There are 2 answers

0
hakre On BEST ANSWER

Many CI systems incl. Scrutinizer CI set environment variables in their build environment.

For example the environment variable SCRUTINIZER is set to TRUE. That is only one of many, learn more about Pre-defined Environment Variables on Scrutinizer CI.

Inside the test method (or inside the setUp() method for the whole class) you can check the environment variable (e.g. via $_ENV) and mark the test as skipped.

if (isset($_ENV['SCRUTINIZER'])) {
    $this->markTestSkipped(
        'Scrutinizer CI build'
    );
}

See as well the more general question How to skip tests in PHPunit? and the Phpunit documentation Incomplete and Skipped Tests.

0
Ravindra Ahire On

In my case, I have added ./vendor/bin/phpunit --exclude-group Group1, Group2 command as follows in .scrutinizer.yml file at application level to skip phpunits representing these groups as follows :

build:
    nodes:
        acsi:
            tests:
                override:
                    - './vendor/bin/phpunit --exclude-group Group1, Group2'
                    - phpcs-run --standard=phpcs.xml
                    - php-scrutinizer-run