coverage: whitelist: exclude option has no effect since PHPUnit 11.0
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
- Codeception version: 5.1.0
- PHP Version: 8.2
- Operating System: Win
- Installation type: Composer
Excluding is no longer supported by phpunit/php-code-coverage library, you must be more specific about what code is included.
At a second glance, implementation of exclude is not that difficult.
Thank you. Exclude is very useful feature, because coverage vendor is useless and often slow.
@zdenekgebauer Could you test my branch by installing "codeception/codeception": "dev-coverage-exclude-for-phpunit11 as 5.1.1" ?
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.
Did your configuration work with PHPUnit 10?
Any chance that you actually have both directories - vendor/ and www/vendor/?
@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).
I created repo https://github.com/zdenekgebauer/test-codecept-exclude with simple test. Excluding vendor stil not working,
@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/*).
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!