Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Extend default XmlReporter to record & report time to run each test method
- */
- class XmlTimeReporter extends XmlReporter
- {
- var $pre;
- /**
- * (non-PHPdoc)
- *
- * @see XmlReporter::paintMethodStart()
- *
- * @param string $test_name the test name
- * @return void
- */
- function paintMethodStart($test_name)
- {
- $this->pre = microtime(TRUE);
- parent::paintMethodStart($test_name);
- }
- /**
- * (non-PHPdoc)
- *
- * @see XmlReporter::paintMethodEnd()
- *
- * @param string $test_name the test name
- * @return void
- */
- function paintMethodEnd($test_name)
- {
- $post = microtime(TRUE);
- if ($this->pre != null) {
- $duration = $post - $this->pre;
- // how can post time be less than pre? assuming zero if this happens..
- if ($post < $this->pre) $duration = 0;
- print $this->_getIndent(1);
- print "<time>$duration</time>\n";
- }
- parent::paintMethodEnd($test_name);
- $this->pre = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement