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.46k stars 341 forks source link

[Bug]: Empty dataset not allowed #1124

Closed CodeWithDennis closed 6 months ago

CodeWithDennis commented 6 months ago

What Happened

I'm currently in the process of developing a FilamentPHP plugin focused on generating tests from Filament Resources. However, I've encountered a hurdle while attempting to create tests with a dataset. Sometimes, there isn't a dataset available, such as when there are no table columns, and in such cases, it defaults to using an empty array. Unfortunately, an empty dataset is not permitted.

For instance, when encountering an empty dataset like this:

it('can individually search by column', function (string $column) {
    // Logic here
})->with([]);

// __pest_evaluable_it_can_individually_search_by_column is invalid Empty data set provided by data provider

To address this issue, I contemplated appending skip to it to entirely skip the test. However, even with this addition, the dataset part of the test still gets executed.

I'm wondering if there's a way to skip the test without executing it at all.

How to Reproduce

Use an empty dataset

it('can individually search by column', function (string $column) {
    // Logic here
})->with([]);

Sample Repository

No response

Pest Version

v2.34.5

PHP Version

v8.2.12

Operation System

macOS

Notes

While I understand this issue may not technically qualify as a bug, I would still greatly appreciate any assistance with it.

fabio-ivona commented 6 months ago

Hi, by writing this way you are giving no datasets at all, so no tests are generated and this is generally an unwanted behavior, as it means something went wrong with tests generation

I think your plugin should not generate the test ad all, in case there are no tests to be generated