コード例 #1
0
 protected function printTestCase(ScenarioNode $scenario, $time, EventInterface $event)
 {
     $className = $this->formatClassname($scenario->getFeature());
     $name = $scenario->getTitle();
     if ($event instanceof OutlineExampleEvent) {
         $name .= sprintf(', Ex #%d', $event->getIteration() + 1);
     }
     $caseStats = sprintf('classname="%s" name="%s" time="%F" assertions="%d"', htmlspecialchars($className), htmlspecialchars($name), $time, $this->scenarioStepsCount);
     $xml = "    <testcase {$caseStats}>\n";
     foreach ($this->exceptions as $exception) {
         $error = $this->exceptionToString($exception);
         $elemType = $this->getElementType($event->getResult());
         $elemAttributes = '';
         if ('skipped' !== $elemType) {
             $elemAttributes = sprintf('message="%s" type="%s"', htmlspecialchars($error), $this->getResultColorCode($event->getResult()));
         }
         $xml .= sprintf('        <%s %s>', $elemType, $elemAttributes);
         $exception = str_replace(['<![CDATA[', ']]>'], '', (string) $exception);
         $xml .= sprintf("<![CDATA[\n%s\n]]></%s>\n", $exception, $elemType);
     }
     $this->exceptions = [];
     $xml .= "    </testcase>";
     $this->testcases[] = $xml;
 }
コード例 #2
0
 /**
  * Prints testcase.
  *
  * @param ScenarioNode   $scenario
  * @param float          $time
  * @param EventInterface $event
  */
 protected function printTestCase(ScenarioNode $scenario, $time, EventInterface $event)
 {
     $className = $scenario->getFeature()->getTitle();
     $name = $scenario->getTitle();
     $name .= $event instanceof OutlineExampleEvent ? ', Ex #' . ($event->getIteration() + 1) : '';
     $caseStats = sprintf('classname="%s" name="%s" time="%F"', htmlspecialchars($className), htmlspecialchars($name), $time);
     $xml = "    <testcase {$caseStats}>\n";
     foreach ($this->exceptions as $exception) {
         $xml .= sprintf('        <failure message="%s" type="%s">', htmlspecialchars($exception->getMessage()), $this->getResultColorCode($event->getResult()));
         $exception = str_replace(array('<![CDATA[', ']]>'), '', (string) $exception);
         $xml .= "<![CDATA[\n{$exception}\n]]></failure>\n";
     }
     $this->exceptions = array();
     $xml .= "    </testcase>";
     $this->testcases[] = $xml;
 }
コード例 #3
0
ファイル: JUnitFormatter.php プロジェクト: ryanhouston/Behat
 /**
  * Prints testcase.
  *
  * @param   Behat\Gherkin\Node\ScenarioNode     $feature
  * @param   float                               $time
  * @param   Behat\Behat\Event\EventInterface    $event
  */
 protected function printTestCase(ScenarioNode $scenario, $time, EventInterface $event)
 {
     $className = $scenario->getFeature()->getTitle() . '.' . $scenario->getTitle();
     $name = $scenario->getTitle();
     $caseStats = sprintf('classname="%s" name="%s" time="%f"', htmlspecialchars($className), htmlspecialchars($name), htmlspecialchars($time));
     $xml = "    <testcase {$caseStats}>\n";
     foreach ($this->exceptions as $exception) {
         $xml .= sprintf('        <failure message="%s" type="%s">' . "\n", htmlspecialchars($exception->getMessage()), $this->getResultColorCode($event->getResult()));
         $xml .= "<![CDATA[\n{$exception}\n]]>";
         $xml .= "        </failure>\n";
     }
     $xml .= "    </testcase>";
     $this->testcases[] = $xml;
 }