pestphp / pest

Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
https://pestphp.com
MIT License
9.06k stars 313 forks source link

[Bug]: Cannot use Datasets in subfolders #1121

Open dantes4ur opened 3 months ago

dantes4ur commented 3 months ago

What Happened

As part of my transition from Laravel 9 to Laravel 10, I am also upgrading from Pest 1.x to 2.x. During this process, I encountered an issue concerning the resolution of datasets located within subfolders.

I'm not the only one with this problem, please refer to [laracast question] for more details. (https://laracasts.com/discuss/channels/testing/pest-global-datasets-not-allowed-in-modular-project)

How to Reproduce

Construct a dataset and place it within a subfolder inside the Datasets directory. Afterwards, execute the command ./vendor/bin/pest MyTest.php, which unfortunately results in a failure.

However, this situation is peculiar as executing the test through PHPStorm does not present any issues, indicating that the problem only occurs when running the test from the terminal...

Sample Repository

No response

Pest Version

2.34.4

PHP Version

8.2.16

Operation System

macOS

Notes

No response

girardotcl commented 3 months ago

Same issue here (it's my post)

fabio-ivona commented 3 months ago

hi, would you mind to share here your test directory structure?

dantes4ur commented 3 months ago

Sure, this is my general structure:

Captura de pantalla 2024-03-26 a la(s) 1 37 25 a m

The core issue lies with the handling of Datasets; specifically, the inability to organize them into a Folder/Subfolder structure, as Pest fails to recognize the dataset in such a configuration. This is particularly rare because this limitation was not present in Pest 1.0 afaik...

Captura de pantalla 2024-03-26 a la(s) 1 39 15 a m

Something defined within ExampleDataset.php and ExampleDataset2.php won't be loaded.

Hope this clarifies the issue

girardotcl commented 2 months ago

Hi !

Thanks for your work.

Any update on this issue ?

fabio-ivona commented 2 months ago

Hi !

Thanks for your work.

Any update on this issue ?

Working on this one, there are some caveats to fix, will be ready in a couple of days

girardotcl commented 2 months ago

Awesome, thank you very much for your work !

fabio-ivona commented 2 months ago

I've found a weird behaviour when running parallel tests, maybe someone's willing to have a deeper look here #1134