-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce <source>
XML configuration element to configure "your code"
#5294
Labels
feature/configuration/xml
feature/test-runner
CLI test runner
type/enhancement
A new idea that should be implemented
Milestone
Comments
sebastianbergmann
added a commit
that referenced
this issue
Apr 2, 2023
…rageIncludeDirectories(), coverageIncludeFiles(), coverageExcludeDirectories(), and coverageExcludeFiles() for #5294
Hi, I'm currently on 07c279b and my suite is warning me with:
But I can't find the proper way to adapt the XML to the new required XSD.
Could be the changelog for 10.1 updated with some more details please? |
This was referenced Apr 13, 2023
maks-rafalko
added a commit
to infection/infection
that referenced
this issue
Apr 14, 2023
…stead of `<coverage />` Fixes #1840 Related to sebastianbergmann/phpunit#5294
maks-rafalko
added a commit
to infection/infection
that referenced
this issue
Apr 14, 2023
…stead of `<coverage />` (#1841) Fixes #1840 Related to sebastianbergmann/phpunit#5294
hofmannsven
added a commit
to hofmannsven/laravel-brevo
that referenced
this issue
Mar 14, 2024
PHPUnit supports the configuration of the `<source>` element starting from version 10.1 (see sebastianbergmann/phpunit#5294).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
feature/configuration/xml
feature/test-runner
CLI test runner
type/enhancement
A new idea that should be implemented
Status Quo
The XML configuration file can already be used to specify which code you are interested in when it comes to code coverage reporting:
The configuration shown above limits the code coverage reporting to
*.php
files in thesrc
directory. Code that is executed while the tests are run that is declared in source code files outside ofsrc
,vendor
, for instance, are not included in code coverage reports.Motivation
As of PHPUnit 10.0, the test runner prints
D
,N
, andW
, respectively, for tests that execute code which triggersE_DEPRECATED
,E_USER_DEPRECATED
,E_NOTICE
,E_USER_NOTICE
,E_STRICT
,E_WARNING
, orE_USER_WARNING
events. Detailed information (which notices was triggered where, for instance) is only printed when--display-deprecations
,--display-notices
, or--display-warnings
is used.The test runner should support limiting the reporting of deprecations, notices, and warnings to "your code", excluding code from directories such as
vendor
, for example. This is covered in #5293.Proposal
In order to limit the reporting of deprecations, notices, and warnings to source code files in specified directories, this information needs to be put into the XML configuration file.
I do not think it makes sense to have two separate configuration elements for configuring the source code you are interested in: one for code coverage and another for the reporting of deprecations, notices, and warnings.
I therefore propose the following:
Step 1
Introduce a new
<source>
element for the XML configuration file:<source>
will be used for limiting the reporting of deprecations, notices, and warnings to the specified directories and files.When
<source>
is present and<coverage>
is absent then<source>
will be used instead of<coverage>
for code coverage filtering.When both
<source>
and<coverage>
are present then<coverage>
will be used for code coverage filtering.Step 2 (in the same version as Step 1)
Deprecate using
<include>
and<exclude>
(and their children<directory>
and<file>
) under<coverage>
to configure code coverage filtering.Implement XML configuration file migrator to migrate from
<coverage>
to<source>
to configure code coverage filtering.Step 3 (in the same version as Step 1)
Change
--generate-configuration
to generate aphpunit.xml
file that uses<source>
instead of<coverage>
to configure code coverage filtering.Step 4 (in the next major version after previous steps)
Remove support for using
<include>
and<exclude>
(and their children<directory>
and<file>
) under<coverage>
to configure code coverage filtering.The text was updated successfully, but these errors were encountered: