Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TestSuite.php

function TestSuite::run

Throws

CodeCoverageException

Event\RuntimeException

Exception

InvalidArgumentException

NoPreviousThrowableException

UnintentionallyCoveredCodeException

Overrides Test::run

File

vendor/phpunit/phpunit/src/Framework/TestSuite.php, line 332

Class

TestSuite
@template-implements IteratorAggregate<int, Test>

Namespace

PHPUnit\Framework

Code

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);
}
RSS feed
Powered by Drupal