Codeception icon indicating copy to clipboard operation
Codeception copied to clipboard

coverage: whitelist: exclude option has no effect since PHPUnit 11.0

Open zdenekgebauer opened this issue 2 years ago • 4 comments

codecept run  --coverage-html 

with configuration

coverage:
    enabled: true
    exclude:
        - vendor/*

causes warning

WARNING: `coverage: whitelist: exclude` option has no effect since PHPUnit 11.0

and vendor directory is not excluded

Details

I found changelog https://github.com/sebastianbergmann/phpunit/blob/9.3.0/ChangeLog-9.3.md#930---2020-08-07 with comment: "Using --whitelist to include a directory in code coverage reports is now deprecated, please use --coverage-filter instead" Is documentation on https://codeception.com/docs/Codecoverage outdated?

  • Codeception version: 5.1.0
  • PHP Version: 8.2
  • Operating System: Win
  • Installation type: Composer

zdenekgebauer avatar Feb 19 '24 18:02 zdenekgebauer

Excluding is no longer supported by phpunit/php-code-coverage library, you must be more specific about what code is included.

Naktibalda avatar Feb 19 '24 18:02 Naktibalda

At a second glance, implementation of exclude is not that difficult.

Naktibalda avatar Feb 19 '24 19:02 Naktibalda

Thank you. Exclude is very useful feature, because coverage vendor is useless and often slow.

zdenekgebauer avatar Feb 19 '24 19:02 zdenekgebauer

@zdenekgebauer Could you test my branch by installing "codeception/codeception": "dev-coverage-exclude-for-phpunit11 as 5.1.1" ?

Naktibalda avatar Feb 19 '24 20:02 Naktibalda

Warning is gone, but coverage report still contains directory tests/_output/coverage/vendor/* . I have project directory structure:

- tests/*
- www/app/*
- www/vendor/*
- codeception.dist.yml

configuration contains:

coverage:
    enabled: true
    include:
        - www/*
    exclude:
        - vendor/*

I tried also

    exclude:
        - www/vendor/*

it makes no difference.

zdenekgebauer avatar Feb 20 '24 07:02 zdenekgebauer

Did your configuration work with PHPUnit 10?

Any chance that you actually have both directories - vendor/ and www/vendor/?

Naktibalda avatar Feb 20 '24 19:02 Naktibalda

@Naktibalda Thank you, tested and works.

I've tested PR on project currently using Codeception + PHPUnit 10. Used Codeception with patch, upgraded PHPUnit to 11, did not changed anything in codeception.yml. Code coverage was generated as expected (HTML report).

KacerCZ avatar Feb 21 '24 07:02 KacerCZ

I created repo https://github.com/zdenekgebauer/test-codecept-exclude with simple test. Excluding vendor stil not working,

zdenekgebauer avatar Feb 21 '24 13:02 zdenekgebauer

@zdenekgebauer You sample repo still uses wrong path - you have to exclude www/vendor.

I found and fixed a bug which produced different fully qualified file names when wildcard pattern was one directory level deep e.g. www/* and when it had more levels (www/vendor/*).

Naktibalda avatar Feb 21 '24 18:02 Naktibalda

I've made an update to the test repository https://github.com/zdenekgebauer/test-codecept-exclude, adding tests to cover files located in various directories. Everything is functioning as expected, including the exclusion of vendor files.

Thank you very much!

zdenekgebauer avatar Feb 22 '24 07:02 zdenekgebauer