Source for file junit_xml_reporter.php
Documentation is available at junit_xml_reporter.php
* @package JunitXMLReporter
* @version $Id: junit_xml_reporter.php 1716 2008-04-04 10:17:54Z pp11 $
* @author Patrice Neff - mailinglists@patrice.ch (original code)
require_once dirname(__FILE__
).
'/../reporter.php';
* Reporter which outputs test results in a format compatible
* with JUnit / Maven XML output. Can be used for integrating
* test suite with continuous integration servers such as
$this->doc =
new DOMDocument();
$this->doc->loadXML('<testsuite/>');
$this->root =
$this->doc->documentElement;
$this->root->setAttribute('name', $test_name);
$this->root->setAttribute('timestamp', date('c'));
$this->root->setAttribute('hostname', 'localhost');
echo
"<?xml version=\"1.0\"?>\n";
echo
"<!-- starting test suite $test_name\n";
* Paints the end of the test with a summary of
* the passes and failures.
* @param string $test_name Name class of test.
$duration =
microtime(true) -
$this->testsStart;
$this->root->setAttribute('failures', $this->getFailCount());
$this->root->setAttribute('time', $duration);
$this->doc->formatOutput =
true;
$xml =
$this->doc->saveXML();
// Cut out XML declaration
echo
"- case start $case\n";
$this->currentCaseName =
$case;
echo
" - test start: $test\n";
$this->currCase =
$this->doc->createElement('testcase');
$duration =
microtime(true) -
$this->methodStart;
$this->currCase->setAttribute('name', $test);
$this->currCase->setAttribute('classname', $this->currentCaseName);
$this->currCase->setAttribute('time', $duration);
$this->root->appendChild($this->currCase);
parent::paintFail($message);
parent::paintException($exception);
$ch =
$this->doc->createElement('failure');
$ch->setAttribute('message', $breadcrumb[count($breadcrumb)-
1]);
$ch->setAttribute('type', $breadcrumb[count($breadcrumb)-
1]);
$message =
implode(' -> ', $breadcrumb) .
"\n\n\n" .
$message;
$content =
$this->doc->createTextNode($message);
$ch->appendChild($content);
$this->currCase->appendChild($ch);
Documentation generated on Sun, 04 May 2008 09:21:43 -0500 by phpDocumentor 1.3.0