Filter tests based on the PHP extensions they require #5928
Labels
feature/configuration/cli
feature/metadata/attributes
feature/test-runner
CLI test runner
type/enhancement
A new idea that should be implemented
Milestone
Consider this test class:
When the test suite that contains the test case shown above is run then the output shown below is printed when the
mysqli
extension is not available in the PHP process that runs PHPUnit and the tests:The test is skipped as its requirements are not met. This is better than triggering PHP errors related to unknown symbols such as classes or functions.
The
RequiresPhpExtension
attribute is commonly used in projects that have optional functionality that requires a PHP extension to work. When this extension is available then the tests are run, when the extension is not available then the tests are skipped.It is sometimes desirable to have separate continuous integration jobs that use different PHP configurations where, for example, some extensions are available or not available. In certain scenarios it would be nice to filter tests based on the PHP extensions they require.
Proposal
Implement a CLI option named
--requires-php-extension mysqli
for PHPUnit's test runner that only runs tests that have a#[RequiresPhpExtension('mysqli')]
attribute.The text was updated successfully, but these errors were encountered: