/** * Runs tests based on the given TestSuite object. * * @param \Stagehand\TestRunner\TestSuite\SimpleTestTestSuite $suite */ public function run($suite) { $textReporter = new TextReporter(); $textReporter->setRunner($this); $textReporter->setTerminal($this->terminal); $reporter = new \MultipleReporter(); $reporter->attachReporter($this->decorateReporter($textReporter)); if ($this->hasJUnitXMLFile()) { $reporter->attachReporter($this->decorateReporter($this->junitXMLReporterFactory->create($this->createJUnitXMLWriter(), $suite))); } $suite->run($reporter); $this->notification = $textReporter->getNotification(); }
/** * Runs tests based on the given TestSuite object. * * @param TestSuite $suite */ public function run($suite) { $reporter = new MultipleReporter(); $reporter->attachReporter($this->decorateReporter(new TextReporter())); if ($this->config->logsResultsInJUnitXML) { if (!$this->config->logsResultsInJUnitXMLInRealtime) { $xmlWriter = new Stagehand_TestRunner_JUnitXMLWriter_JUnitXMLDOMWriter(array($this, 'writeJUnitXMLToFile')); } else { $xmlWriter = $this->junitXMLStreamWriter(array($this, 'writeJUnitXMLToFile')); } $junitXMLReporter = new $this->junitXMLReporterClass($this->config); $junitXMLReporter->setXMLWriter($xmlWriter); $junitXMLReporter->setTestSuite($suite); $junitXMLReporter->setConfig($this->config); $reporter->attachReporter($this->decorateReporter($junitXMLReporter)); } ob_start(); $suite->run($reporter); $output = ob_get_contents(); ob_end_clean(); if ($this->config->logsResultsInJUnitXML) { if (is_resource($this->junitXMLFileHandle)) { fclose($this->junitXMLFileHandle); } } if ($this->config->usesGrowl) { if (preg_match('/^(OK.+)/ms', $output, $matches)) { $this->notification->name = 'Green'; $this->notification->description = $matches[1]; } elseif (preg_match('/^(FAILURES.+)/ms', $output, $matches)) { $this->notification->name = 'Red'; $this->notification->description = $matches[1]; } } if ($this->config->colors) { print Console_Color::convert(preg_replace(array('/^(OK.+)/ms', '/^(FAILURES!!!.+)/ms', '/^(\\d+\\)\\s)(.+at \\[.+\\]$\\s+in .+)$/m', '/^(Exception \\d+!)/m', '/^(Unexpected exception of type \\[.+\\] with message \\[.+\\] in \\[.+\\]$\\s+in .+)$/m'), array('%g$1%n', '%r$1%n', "\$1%r\$2%n", '%p$1%n', '%p$1%n'), Console_Color::escape($output))); } else { print $output; } }
/** * @param $suite */ private function execute($suite) { $counter = new SimpleTestCountResultFormatter(); $reporter = new MultipleReporter(); $reporter->attachReporter($counter); foreach ($this->formatters as $fe) { // SimpleTest 1.0.1 workaround $formatterList[] = $fe->getFormatter(); $reporter->attachReporter(end($formatterList)); } $suite->run($reporter); $retcode = $counter->getRetCode(); if ($retcode == SimpleTestCountResultFormatter::ERRORS) { if ($this->errorproperty) { $this->project->setNewProperty($this->errorproperty, true); } if ($this->haltonerror) { $this->testfailed = true; } } elseif ($retcode == SimpleTestCountResultFormatter::FAILURES) { if ($this->failureproperty) { $this->project->setNewProperty($this->failureproperty, true); } if ($this->haltonfailure) { $this->testfailed = true; } } }