Merge pull request #975 from Katalam/repeat

[2.x] Sharing `repeat` iteration as `dataset` variable
This commit is contained in:
Nuno Maduro
2024-01-25 15:01:34 +00:00
committed by GitHub
3 changed files with 34 additions and 2 deletions

View File

@ -265,7 +265,12 @@ trait Testable
$method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name());
if ($method->repetitions > 1) {
array_shift($arguments);
// If the test is repeated, the first argument is the iteration number
// we need to move it to the end of the arguments list
// so that the datasets are the first n arguments
// and the iteration number is the last argument
$firstArgument = array_shift($arguments);
$arguments[] = $firstArgument;
}
$underlyingTest = Reflection::getFunctionVariable($this->__test, 'closure');

View File

@ -117,7 +117,7 @@ final class TestCaseMethodFactory
*/
public function receivesArguments(): bool
{
return $this->datasets !== [] || $this->depends !== [];
return $this->datasets !== [] || $this->depends !== [] || $this->repetitions > 1;
}
/**