a result is a little more than just a PASS/FAIL: 1. we need to know what happened during this phase 2. we need to know how this affects the playing of the story 3. we need to know if there are any other phases we need to execute *because* we have executed this phase 4. we need to know if there's a message to pass on to the end-user perhaps it was much easier when we just hard-coded all of this?
Author: Stuart Herbert (stuart.herbert@datasift.com)
Exemple #1
0
 /**
  *
  * @param  StoryTeller $st
  * @param  Injectables $injectables
  * @param  Phase       $phase
  * @param  boolean     $isActive
  * @return Phase_Result
  */
 public function playPhase(StoryTeller $st, Injectables $injectables, Phase $phase, $isActive, $thingBeingPlayed = null)
 {
     // shorthand
     $output = $st->getOutput();
     $phaseName = $phase->getPhaseName();
     // run the phase if we're allowed to
     if ($isActive) {
         $st->setCurrentPhase($phase);
         $phaseResult = $phase->doPhase($thingBeingPlayed);
     } else {
         $phaseResult = new Phase_Result($phaseName);
         $phaseResult->setContinuePlaying($phaseResult::SKIPPED);
         $output->logPhaseSkipped($phaseName, self::MSG_PHASE_NOT_ACTIVE);
     }
     // close off any open log actions
     $st->closeAllOpenActions();
     // stop any running test devices
     if (!$st->getPersistDevice()) {
         $st->stopDevice();
     }
     // close off any log actions left open by closing down
     // the test device
     $st->closeAllOpenActions();
     // all done
     return $phaseResult;
 }
Exemple #2
0
 /**
  * @param Phase_Result $phaseResult
  */
 protected function showActivityForPhase(Story $story, Phase_Result $phaseResult)
 {
     // what is the phase that we are dealing with?
     $phaseName = $phaseResult->getPhaseName();
     $activityLog = $phaseResult->activityLog;
     // our final messages to show the user
     $codePoints = [];
     $trace = null;
     // does the phase have an exception?
     $e = $phaseResult->getException();
     if ($e) {
         $stackTrace = $e->getTrace();
         $trace = $e->getTraceAsString();
     }
     // let's tell the user what we found
     $this->write("=============================================================" . PHP_EOL, $this->writer->commentStyle);
     $this->write("DETAILED ERROR REPORT" . PHP_EOL);
     $this->write("----------------------------------------" . PHP_EOL . PHP_EOL, $this->writer->commentStyle);
     $this->write("The story failed in the ");
     $this->write($phaseName, $this->writer->failedPhaseStyle);
     $this->write(" phase." . PHP_EOL);
     if (!empty($activityLog)) {
         $this->write(PHP_EOL . "-----" . PHP_EOL, $this->writer->commentStyle);
         $this->write("This is the detailed output from the ");
         $this->write($phaseName, $this->writer->failedPhaseStyle);
         $this->write(" phase:" . PHP_EOL . PHP_EOL);
         foreach ($activityLog as $msg) {
             $this->writeActivity($msg['text'], $msg['codeLine'], $msg['ts']);
         }
     }
     if ($trace !== null) {
         $this->write(PHP_EOL . "-----" . PHP_EOL, $this->writer->commentStyle);
         $this->write("This is the stack trace for this failure:" . PHP_EOL . PHP_EOL . CodeFormatter::indentBySpaces($trace, 4) . PHP_EOL . PHP_EOL);
     }
     // all done
     $this->write("----------------------------------------" . PHP_EOL, $this->writer->commentStyle);
     $this->write("END OF ERROR REPORT" . PHP_EOL);
     $this->write("=============================================================" . PHP_EOL . PHP_EOL, $this->writer->commentStyle);
 }