-
-
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
Lazy dataprovider loading #3191
Comments
Depends on #10. |
note: currently there is a possibility to filter tests by data provider label, this shall not be broken |
Just to clarify, you are referring to This works with the caveat that the current mechanism discovers available tests by instantiation and then simply using the Frankly, I am not too familiar with the ins and outs of
|
example of data provider: public function provideFoo() {
return [
'foo_bar' => [1, 2],
'baz_123' => [3, 4],
];
} then, you can |
@keradus Yes, this scenario works in the prototype. It did require some new logic to check if a dataprovider requires being loaded for filtering to work, but yes, this works fine! |
Hooray! I've got some first results as of yesterday:
Benefits of improved data provider handling
Opportunities for further improvement
TestingThe effect of on-demand creation of tests based on
Notes
|
out of curiosity, can you elaborate that logic? like, how to detect if dataprovider shall be loaded or not to filter by keys provided by dataprovider ? |
Unfortunately there is no magic here. Filtering by name requires the names to be available which in turn forces us to load the data provider. This works by loading the data upon Many optimizations came to mind, introducing their own edge cases. Any ideas welcome as always! I intend to build a proper implementation and your critical eye is very much appreciated. |
if @keradus orders a meal in a restaurant, does the kitchen iterate through the whole menu only to return his order? |
ping @SamMousa on-demand data providers are a possible :) |
if @epdenouden ordered anything with salami, does the kitchen knows where to look for it, or iterate over all dishes ingredients? problematic part is that we can filter not only by items (test classes, methods) but also ingredients (case description) |
It will iterate through al dishes looking for salami as an ingredient. This works by simply reverting to the old data provider behaviour when a It might be possible, though! I am not (yet) familiar enough with the whole test filtering logic. |
Superseded by #3736 |
It may happen that a lot of great effort made to improve data providers will be simply ignored due to fact that someone used a filter to run only some or the tests ? What a pity, I almost always use filtering, @epdenouden |
This is not a bug, but more of a feature request / proposal.
Currently the result of a dataprovider is always traversed, meaning that a generator will be fully traversed before the first test starts.
This approach has several downsides:
Changes required would be relatively minor.
PHPUnit\Util\Test::getProvidedData()
return type should be changed to?Traversable
.Traversable
.TestSuite::createTest()
needs some minor changes (can't check if aTraversable
is empty).I'm open for implementing if there's agreement that this would be an improvement.
The text was updated successfully, but these errors were encountered: