Beispiel #1
0
 public function finish()
 {
     $failures = 0;
     if ($this->retriever instanceof CrawlingRetriever) {
         $startPage = (string) $this->retriever->getStartPage();
     } else {
         $startPage = '';
     }
     $xUnitReport = new XUnitReport($startPage);
     foreach ($this->results as $result) {
         $testCase = new TestCase($result->getUrl(), $result->getUrl(), $result->getDuration());
         if ($result->isFailure()) {
             ++$failures;
             foreach ($result->getMessages() as $ruleName => $message) {
                 $testCase->addFailure(new Failure($ruleName, $message));
                 if ($this->retriever instanceof CrawlingRetriever) {
                     $stackTrace = $result->getUrl() . ' coming from ' . (string) $this->retriever->getComingFrom($result->getUrl()) . PHP_EOL;
                     $stackTrace .= '    - ' . $message . " [rule: {$ruleName}]";
                     $testCase->setSystemOut($stackTrace);
                 }
             }
         }
         $xUnitReport->addTestCase($testCase);
     }
     file_put_contents($this->filename, $xUnitReport->toXml());
     $this->output->writeln('    <info>Writing XUnit Output to file:</info> ' . $this->filename);
 }
Beispiel #2
0
 public function getReport()
 {
     foreach ($this->tests as $url => $missingUrls) {
         $testCase = new TestCase('MissingRequest', $url, 0);
         foreach ($missingUrls as $missingUrl) {
             if ($missingUrl !== false) {
                 $testCase->addFailure(new Failure('Missing request', 'Request was not found (' . $missingUrl . ')'));
             }
         }
         $this->report->addTestCase($testCase);
     }
     return $this->report->toXml();
 }