9 use Codeception\Events;
35 Events::TEST_START =>
'testStart',
36 Events::TEST_FAIL =>
'testFail',
37 Events::STEP_AFTER =>
'afterStep',
38 Events::TEST_END =>
'testEnd' 40 self::$events = array_merge(parent::$events,
$events);
41 parent::_initialize();
60 public function testFail(\Codeception\Event\FailEvent $e)
62 $cest = $e->getTest();
63 $context = $this->
extractContext($e->getFail()->getTrace(), $cest->getTestMethod());
67 $this->runAfterBlock($e, $cest);
77 public function testEnd(\Codeception\Event\TestEvent $e)
79 $cest = $e->getTest();
83 function () use ($cest) {
84 return $cest->getTestResultObject();
88 $errors = $testResultObject->errors();
91 if ($error->failedTest()->getTestMethod() == $cest->getName()) {
92 $stack =
$errors[0]->thrownException()->getTrace();
97 $this->runAfterBlock($e, $cest);
104 $this->
getDriver()->_runAfter($e->getTest());
113 private function runAfterBlock($e, $cest)
116 $actorClass = $e->getTest()->getMetadata()->getCurrent(
'actor');
117 $I =
new $actorClass($cest->getScenario());
119 function () use ($cest, $I) {
120 $cest->executeHook($I,
'after');
125 }
catch (\Exception $e) {
138 foreach ($trace as $entry) {
139 $traceClass = $entry[
"class"] ??
null;
140 if (strpos($traceClass,
$class) != 0) {
141 return $entry[
"function"];
169 public function afterStep(\Codeception\Event\StepEvent $e)
beforeStep(\Codeception\Event\StepEvent $e)
call_user_func($callable, $param)
extractContext($trace, $class)
$_option $_optionId $class
afterStep(\Codeception\Event\StepEvent $e)
testFail(\Codeception\Event\FailEvent $e)
testEnd(\Codeception\Event\TestEvent $e)