function TestSuite::run
Throws
Event\RuntimeException
UnintentionallyCoveredCodeException
Overrides Test::run
File
-
vendor/
phpunit/ phpunit/ src/ Framework/ TestSuite.php, line 332
Class
- TestSuite
- @template-implements IteratorAggregate<int, Test>
Namespace
PHPUnit\FrameworkCode
public function run() : void {
if ($this->wasRun) {
// @codeCoverageIgnoreStart
throw new Exception('The tests aggregated by this TestSuite were already run');
// @codeCoverageIgnoreEnd
}
$this->wasRun = true;
if ($this->isEmpty()) {
return;
}
$emitter = Event\Facade::emitter();
$testSuiteValueObjectForEvents = Event\TestSuite\TestSuiteBuilder::from($this);
$emitter->testSuiteStarted($testSuiteValueObjectForEvents);
if (!$this->invokeMethodsBeforeFirstTest($emitter, $testSuiteValueObjectForEvents)) {
return;
}
/** @psalm-var list<Test> $tests */
$tests = [];
foreach ($this as $test) {
$tests[] = $test;
}
$tests = array_reverse($tests);
$this->tests = [];
$this->groups = [];
while (($test = array_pop($tests)) !== null) {
if (TestResultFacade::shouldStop()) {
$emitter->testRunnerExecutionAborted();
break;
}
$test->run();
}
$this->invokeMethodsAfterLastTest($emitter);
$emitter->testSuiteFinished($testSuiteValueObjectForEvents);
}