Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail hard if test has impossible dependency #4599

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/Codeception/Suite.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ public function reorderDependencies()
}
$this->tests = $queue;
}

protected function getDependencies($test)
{
if (!$test instanceof Dependent) {
return [$test];
}
$forTest = Descriptor::getTestSignature($test);
$tests = [];
foreach ($test->getDependencies() as $requiredTestName) {
$required = $this->findMatchedTest($requiredTestName);
$required = $this->findMatchedTest($requiredTestName, $forTest);
if (!$required) {
continue;
}
Expand All @@ -43,17 +45,17 @@ protected function getDependencies($test)
$tests[] = $test;
return $tests;
}
protected function findMatchedTest($testSignature)

protected function findMatchedTest($testSignature, $forTest)
{
foreach ($this->tests as $test) {
$signature = Descriptor::getTestSignature($test);
if ($signature === $testSignature) {
return $test;
}
}
if ($test instanceof TestInterface) {
$test->getMetadata()->setSkip("Dependent test for $testSignature not found");
}

throw new \Exception("Dependent test $testSignature for $forTest not found");
}

/**
Expand Down