You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To access the ResultAggregator from within the _failed method in a Codeception module.
What do you get instead?
php vendor/bin/codecept run Unit -vvv
In TestCaseWrapper.php line 86:
[LogicException]
ResultAggregator is not set
Both Codeception\Test\Test and Codeception\Test\TestCaseWrapper (which extends Test) have the private property $resultAggregator on them so the following code:
Note the duplicate keys for resultAggregator but with different class prefixes.
I have a very hacky way of retrieving the ResultAggregator using the following:
$reflected = new \ReflectionClass($test);
$reflectedIterable = $reflected;
while ($parentReflected = $reflectedIterable->getParentClass()) {
if (Test::class === $parentReflected->getName()) {
$privateProperty = $parentReflected->getProperty('resultAggregator');
$result = $privateProperty->getValue($test);
}
$reflectedIterable = $parentReflected;
}
// result should be set now - check it's not null before using$result->shouldStop(); // etc
Demo repo
This demo repo contains an out-of-the-box installation of Codeception 5 (with extraneous suites removed) and a basic helper which demonstrates the bug.
What are you trying to achieve?
To access the
ResultAggregator
from within the_failed
method in a Codeception module.What do you get instead?
In TestCaseWrapper.php line 86: [LogicException] ResultAggregator is not set
Both
Codeception\Test\Test
andCodeception\Test\TestCaseWrapper
(which extendsTest
) have the private property$resultAggregator
on them so the following code:Generates the output (values have been truncated):
Note the duplicate keys for
resultAggregator
but with different class prefixes.I have a very hacky way of retrieving the
ResultAggregator
using the following:Demo repo
This demo repo contains an out-of-the-box installation of Codeception 5 (with extraneous suites removed) and a basic helper which demonstrates the bug.
Demo repository, in particular the FailureHelper.
Details
The text was updated successfully, but these errors were encountered: