public function failed(\Codeception\Event\Fail $e) { if (!$e->getTest() instanceof TestCase) { return; } foreach (\Codeception\SuiteManager::$modules as $module) { $module->_failed($e->getTest(), $e->getFail()); } }
public function failedTest(\Codeception\Event\Fail $e) { if (!$e->getTest() instanceof \Codeception\TestCase\Cest) { return; } $test = $e->getTest(); if (method_exists($test->getTestClass(), '_failed')) { $test->getTestClass()->_failed($e); } }
public function printFail(\Codeception\Event\Fail $e) { $failedTest = $e->getTest(); $fail = $e->getFail(); if ($fail instanceof \PHPUnit_Framework_SelfDescribing) { $failToString = \PHPUnit_Framework_TestFailure::exceptionToString($fail); } else { $failToString = sprintf("[%s]\n%s", get_class($fail), $fail->getMessage()); } $feature = $failedTest->getScenario()->getFeature(); if ($e->getCount()) { $this->output->put($e->getCount() . ") "); } // skip test // Sample Message: create user in CreateUserCept.php is not ready for release if ($fail instanceof \PHPUnit_Framework_SkippedTest or $fail instanceof \PHPUnit_Framework_IncompleteTest) { if ($feature) { $this->output->put("[[{$feature}]] in "); } $this->output->put($failedTest->getFilename()); if ($failToString) { $this->output->put(" is " . $failToString); } $this->output->writeln("\n"); return; } if ($feature) { $this->output->put("Couldn't [[{$feature}]] in "); } $this->output->writeln('((' . $failedTest->getFilename() . '))'); $trace = array_reverse($failedTest->getTrace()); $length = $i = count($trace); $last = array_shift($trace); if (!method_exists($last, 'getHumanizedAction')) { $this->printException($fail); return; } $action = $last->getHumanizedAction(); if (strpos($action, "am") === 0) { $action = 'become' . substr($action, 2); } // it's exception if (!$fail instanceof \PHPUnit_Framework_AssertionFailedError) { $this->printException($fail); return; } // it's assertion if (strpos($action, "don't") === 0) { $action = substr($action, 6); $this->output->writeln("Guy unexpectedly managed to {$action}:\n{$failToString}"); } else { $this->output->writeln("Guy couldn't {$action}: {$failToString}"); } $this->output->writeln("Scenario Steps:"); $this->output->writeln("{$i}. (!{$last}!)"); foreach ($trace as $step) { $i--; $this->output->writeln("{$i}. " . $step); if ($length - $i - 1 >= $this->traceLength) { break; } } if ($this->debug) { $this->printException($fail); } }
public function testError(\Codeception\Event\Fail $e) { $this->logger->alert($e->getFail()->getMessage()); $this->logger->info("# ERROR #"); }
public function printFail(\Codeception\Event\Fail $e) { $failedTest = $e->getTest(); $fail = $e->getFail(); $this->output->write($e->getCount() . ") "); if ($e->getTest() instanceof ScenarioDriven) { $this->printScenarioFail($failedTest, $fail); return; } $failToString = \PHPUnit_Framework_TestFailure::exceptionToString($fail); $this->message(get_class($failedTest))->append('::')->append($failedTest->getName())->style('bold')->append("\n")->append($failToString)->writeln(); $this->printException($fail); }
public function printFail(\Codeception\Event\Fail $e) { $failedTest = $e->getTest(); $fail = $e->getFail(); $failToString = \PHPUnit_Framework_TestFailure::exceptionToString($fail); $feature = $failedTest->getScenario()->getFeature(); $this->output->put("\nCouldn't {$feature}"); $this->output->put(" ({$failedTest->getFilename()})\n"); $trace = array_reverse($failedTest->getTrace()); $length = $i = count($trace); $last = array_shift($trace); if (!method_exists($last, 'getHumanizedAction')) { if (!$this->debug) { $this->output->writeln($failToString); return; } $this->output->writeln($this->printException('not an action', $fail)); return; } $action = $last->getHumanizedAction(); if (strpos($action, "am") === 0) { $action = 'become' . substr($action, 2); } // it's exception if (!$fail instanceof \PHPUnit_Framework_AssertionFailedError) { if ($this->debug) { $this->printException($last->getAction(), $fail); } else { $this->output->writeln('to see the stack trace run this test with --debug option'); } return; } // it's assertion if (strpos($action, "don't") === 0) { $action = substr($action, 6); $this->output->writeln("\nGuy unexpectedly managed to {$action} {$failToString}"); } else { $this->output->writeln("Guy couldn't {$action} {$failToString}"); } $this->output->writeln(" {$i}. (!{$last}!)"); foreach ($trace as $step) { $i--; $this->output->writeln(" {$i}. " . $step); if ($length - $i - 1 >= $this->traceLength) { break; } } $this->output->writeln(""); }
public function failed(\Codeception\Event\Fail $e) { foreach (\Codeception\SuiteManager::$modules as $module) { $module->_failed($e->getTest(), $e->getFail()); } }