diff --git a/src/Repositories/TestRepository.php b/src/Repositories/TestRepository.php index b2eb4893..305dc127 100644 --- a/src/Repositories/TestRepository.php +++ b/src/Repositories/TestRepository.php @@ -5,11 +5,13 @@ declare(strict_types=1); namespace Pest\Repositories; use Closure; +use Pest\Exceptions\DatasetMissing; use Pest\Exceptions\ShouldNotHappen; use Pest\Exceptions\TestAlreadyExist; use Pest\Exceptions\TestCaseAlreadyInUse; use Pest\Exceptions\TestCaseClassOrTraitNotFound; use Pest\Factories\TestCaseFactory; +use Pest\Support\Reflection; use Pest\Support\Str; use Pest\TestSuite; use PHPUnit\Framework\TestCase; @@ -140,6 +142,14 @@ final class TestRepository throw new TestAlreadyExist($test->filename, $test->description); } + if ($test->dependent === false && count($test->datasets) === 0) { + $arguments = Reflection::getFunctionArguments($test->test); + + if (count($arguments) > 0) { + throw new DatasetMissing($test->filename, $test->description, $arguments); + } + } + $this->state[sprintf('%s%s%s', $test->filename, self::SEPARATOR, $test->description)] = $test; } }