-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add (opt-in?) support for data providers returning an empty iterable #6404
Copy link
Copy link
Open
Labels
feature/data-providerData ProvidersData Providerstype/enhancementA new idea that should be implementedA new idea that should be implemented
Description
When the data provider generates test cases based on some external sources, it might happen that there is no cases to be tested.
As PHPUnit triggers an error when a data provider returns an empty iterable (technically when all providers configured for a test do it, so that the merged result is empty, but most tests don't use multiple data providers), such projects end up doing hacks where they yield a single case in the data provider with special values that the test detects to call markTestSkipped.
Examples:
- async-aws having a test enforcing that modified services include updates to their changelog (a PR might not modify any of the files requiring changelog entries): Skip changelog's test when the dataprovider returns nothing async-aws/aws#1983
- the
IntegrationTestCaseof Twig has a dedicated test running the "legacy" test cases, where deprecations are ignored. A project running Twig integration tests might not have any legacy tests: https://github.com/twigphp/Twig/blob/d58c8be15ddbda8532df7ba5de283b51dd8939d2/src/Test/IntegrationTestCase.php#L191
It would be great to have a way to opt-out of that error, marking the tests as skipped due to no provided data instead.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature/data-providerData ProvidersData Providerstype/enhancementA new idea that should be implementedA new idea that should be implemented