Exemplo n.º 1
0
 /**
  * @param $failedTest
  * @param $fail
  */
 public function printScenarioTrace(ScenarioDriven $failedTest)
 {
     $trace = array_reverse($failedTest->getScenario()->getSteps());
     $length = $i = count($trace);
     if (!$length) {
         return;
     }
     $this->message("\nScenario Steps:\n")->style('comment')->writeln();
     foreach ($trace as $step) {
         $message = $this->message($i)->prepend(' ')->width(strlen($length))->append(". " . $step->getPhpCode());
         if ($step->hasFailed()) {
             $message->append('')->style('bold');
         }
         $line = $step->getLine();
         if ($line and !$step instanceof Comment) {
             $message->append(" at <info>{$line}</info>");
         }
         $i--;
         $message->writeln();
         if ($length - $i - 1 >= $this->traceLength) {
             break;
         }
     }
     $this->output->writeln("");
 }
Exemplo n.º 2
0
    protected function printScenarioFail(ScenarioDriven $failedTest, $fail)
    {
        $feature = $failedTest->getFeature();
        $failToString = \PHPUnit_Framework_TestFailure::exceptionToString($fail);
        $failMessage = $this->message($failedTest->getSignature())
            ->style('bold')
            ->append(' (')
            ->append($failedTest->getFileName())
            ->append(')');

        if ($fail instanceof \PHPUnit_Framework_SkippedTest
            or $fail instanceof \PHPUnit_Framework_IncompleteTest
        ) {
            $this->printSkippedTest($feature, $failedTest->getFileName(), $failToString);
            return;
        }
        if ($feature) {
            $failMessage->prepend("Failed to $feature in ");
        }
        $failMessage->writeln();
        $this->printScenarioTrace($failedTest, $failToString);
        if ($this->output->getVerbosity() == OutputInterface::VERBOSITY_DEBUG) {
            $this->printException($fail);
            return;
        }
        if (!$fail instanceof \PHPUnit_Framework_AssertionFailedError) {
            $this->printException($fail);
            return;
        }
    }