public function printFail(FailEvent $e) { $failedTest = $e->getTest(); $fail = $e->getFail(); $this->output->write($e->getCount() . ") "); $this->writeCurrentTest($failedTest, false); $this->output->writeln(''); $this->message("<error> Test </error> ")->append(codecept_relative_path(Descriptor::getTestFullName($failedTest)))->write(); if ($failedTest instanceof ScenarioDriven) { $this->printScenarioFail($failedTest, $fail); return; } $this->printException($fail); $this->printExceptionTrace($fail); }
public function getLine() { if ($this->line && $this->file) { return codecept_relative_path($this->file) . ':' . $this->line; } }
/** * Finds config files in given wildcarded include path. * Returns the expanded paths or the original if not a wildcard. * * @param $include * @return array * @throws ConfigurationException */ protected static function expandWildcardsFor($include) { if (1 !== preg_match('/[\\?\\.\\*]/', $include)) { return [$include]; } try { $configFiles = Finder::create()->files()->name('/codeception(\\.dist\\.yml|\\.yml)/')->in(self::$dir . DIRECTORY_SEPARATOR . $include); } catch (\InvalidArgumentException $e) { throw new ConfigurationException("Configuration file(s) could not be found in \"{$include}\"."); } $paths = []; foreach ($configFiles as $file) { $paths[] = codecept_relative_path($file->getPath()); } return $paths; }
protected function printScenarioFail(ScenarioDriven $failedTest, $fail) { $feature = $failedTest->getFeature(); $failToString = \PHPUnit_Framework_TestFailure::exceptionToString($fail); $failMessage = $this->message($failedTest->getSignature())->style('bold')->append(' (')->append(codecept_relative_path($failedTest->getFileName()))->append(')'); if ($fail instanceof \PHPUnit_Framework_SkippedTest || $fail instanceof \PHPUnit_Framework_IncompleteTest) { $this->printSkippedTest($feature, $failedTest->getFileName(), $failToString); return; } if ($feature) { $failMessage->prepend("Failed to {$feature} in "); } $failMessage->writeln(); $failedStep = ""; foreach ($failedTest->getScenario()->getSteps() as $step) { if ($step->hasFailed()) { $failedStep = (string) $step; break; } } $this->printException($fail, $failedStep); $this->printScenarioTrace($failedTest, $failToString); if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_DEBUG) { $this->printExceptionTrace($fail); return; } if (!$fail instanceof \PHPUnit_Framework_AssertionFailedError) { $this->printExceptionTrace($fail); return; } }
public function getSignature() { return codecept_relative_path($this->getFileName()); }