From ac1861095bf7e81226c485792e13391405fd0fec Mon Sep 17 00:00:00 2001 From: Megan Watson Date: Tue, 27 Jan 2009 07:12:00 +0000 Subject: [PATCH] Reduced the amount of output produced by the tests - added a parameter to view all. Made the fails stand out a bit more. --- tests/runtests.php | 5 ++++- tests/test.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/tests/runtests.php b/tests/runtests.php index 2f2e6f7..ac91a51 100644 --- a/tests/runtests.php +++ b/tests/runtests.php @@ -37,6 +37,9 @@ $test = &new UnitTests(); if (SimpleReporter::inCli()) { exit ($test->run(new KTTextReporter()) ? 0 : 1); } -$test->run(new KTHtmlReporter()); + +// pass parameter ?show=all to display all passes +$param = (isset($_REQUEST['show']) && $_REQUEST['show'] == 'all') ? true : false; +$test->run(new KTHtmlReporter($param)); ?> \ No newline at end of file diff --git a/tests/test.php b/tests/test.php index 4a88662..6a08808 100644 --- a/tests/test.php +++ b/tests/test.php @@ -53,6 +53,26 @@ class KTUnitTestCase extends UnitTestCase { * */ class KTHtmlReporter extends HtmlReporter { + + /** + * Display all test output + * + * @var bool + */ + protected $show; + + /** + * Does nothing yet. The first output will + * be sent on the first test start. For use + * by a web browser. + * @access public + */ + function KTHtmlReporter($show = false) { + $this->HtmlReporter(); + $this->show = $show; + } + + /** * Display the passed tests * @@ -61,11 +81,46 @@ class KTHtmlReporter extends HtmlReporter { function paintPass($message) { parent::paintPass($message); - print "Pass: "; + if($this->show){ + print "PASS: "; + $breadcrumb = $this->getTestList(); + array_shift($breadcrumb); + print implode("->", $breadcrumb); + print "->$message
\n"; + } + } + + /** + * Paints the test failure with a breadcrumbs + * trail of the nesting test suites below the + * top level test. + * @param string $message Failure message displayed in + * the context of the other tests. + * @access public + */ + function paintFail($message) { + SimpleScorer::paintFail($message); + + print "FAIL: "; + $breadcrumb = $this->getTestList(); + array_shift($breadcrumb); + print implode(" -> ", $breadcrumb); + print " -> " . $this->_htmlEntities($message) . "
\n"; + } + + /** + * Paints a PHP error. + * @param string $message Message is ignored. + * @access public + */ + function paintError($message) { + SimpleScorer::paintError($message); + + print "EXCEPTION: "; $breadcrumb = $this->getTestList(); array_shift($breadcrumb); - print implode("->", $breadcrumb); - print "->$message
\n"; + print implode(" -> ", $breadcrumb); + print " -> " . $this->_htmlEntities($message) . "
\n"; } /** @@ -75,7 +130,8 @@ class KTHtmlReporter extends HtmlReporter { */ function paintMethodStart($test_name) { parent::paintMethodStart($test_name); - print "
Method start: $test_name
"; + if($this->show) print "
"; + print "Method: $test_name
"; } /** -- libgit2 0.21.4