Commit ac1861095bf7e81226c485792e13391405fd0fec
1 parent
884a5c08
Reduced the amount of output produced by the tests - added a parameter to view a…
…ll. Made the fails stand out a bit more. Committed by: Megan Watson Reviewed by: Kevin Cyster git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@9753 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
64 additions
and
5 deletions
tests/runtests.php
| ... | ... | @@ -37,6 +37,9 @@ $test = &new UnitTests(); |
| 37 | 37 | if (SimpleReporter::inCli()) { |
| 38 | 38 | exit ($test->run(new KTTextReporter()) ? 0 : 1); |
| 39 | 39 | } |
| 40 | -$test->run(new KTHtmlReporter()); | |
| 40 | + | |
| 41 | +// pass parameter ?show=all to display all passes | |
| 42 | +$param = (isset($_REQUEST['show']) && $_REQUEST['show'] == 'all') ? true : false; | |
| 43 | +$test->run(new KTHtmlReporter($param)); | |
| 41 | 44 | |
| 42 | 45 | ?> |
| 43 | 46 | \ No newline at end of file | ... | ... |
tests/test.php
| ... | ... | @@ -53,6 +53,26 @@ class KTUnitTestCase extends UnitTestCase { |
| 53 | 53 | * |
| 54 | 54 | */ |
| 55 | 55 | class KTHtmlReporter extends HtmlReporter { |
| 56 | + | |
| 57 | + /** | |
| 58 | + * Display all test output | |
| 59 | + * | |
| 60 | + * @var bool | |
| 61 | + */ | |
| 62 | + protected $show; | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * Does nothing yet. The first output will | |
| 66 | + * be sent on the first test start. For use | |
| 67 | + * by a web browser. | |
| 68 | + * @access public | |
| 69 | + */ | |
| 70 | + function KTHtmlReporter($show = false) { | |
| 71 | + $this->HtmlReporter(); | |
| 72 | + $this->show = $show; | |
| 73 | + } | |
| 74 | + | |
| 75 | + | |
| 56 | 76 | /** |
| 57 | 77 | * Display the passed tests |
| 58 | 78 | * |
| ... | ... | @@ -61,11 +81,46 @@ class KTHtmlReporter extends HtmlReporter { |
| 61 | 81 | function paintPass($message) { |
| 62 | 82 | parent::paintPass($message); |
| 63 | 83 | |
| 64 | - print "<span class=\"pass\">Pass</span>: "; | |
| 84 | + if($this->show){ | |
| 85 | + print "<span class=\"pass\">PASS</span>: "; | |
| 86 | + $breadcrumb = $this->getTestList(); | |
| 87 | + array_shift($breadcrumb); | |
| 88 | + print implode("->", $breadcrumb); | |
| 89 | + print "->$message<br />\n"; | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Paints the test failure with a breadcrumbs | |
| 95 | + * trail of the nesting test suites below the | |
| 96 | + * top level test. | |
| 97 | + * @param string $message Failure message displayed in | |
| 98 | + * the context of the other tests. | |
| 99 | + * @access public | |
| 100 | + */ | |
| 101 | + function paintFail($message) { | |
| 102 | + SimpleScorer::paintFail($message); | |
| 103 | + | |
| 104 | + print "<span class=\"fail\"><b>FAIL</b></span>: "; | |
| 105 | + $breadcrumb = $this->getTestList(); | |
| 106 | + array_shift($breadcrumb); | |
| 107 | + print implode(" -> ", $breadcrumb); | |
| 108 | + print " -> " . $this->_htmlEntities($message) . "<br />\n"; | |
| 109 | + } | |
| 110 | + | |
| 111 | + /** | |
| 112 | + * Paints a PHP error. | |
| 113 | + * @param string $message Message is ignored. | |
| 114 | + * @access public | |
| 115 | + */ | |
| 116 | + function paintError($message) { | |
| 117 | + SimpleScorer::paintError($message); | |
| 118 | + | |
| 119 | + print "<span class=\"fail\"><b>EXCEPTION</b></span>: "; | |
| 65 | 120 | $breadcrumb = $this->getTestList(); |
| 66 | 121 | array_shift($breadcrumb); |
| 67 | - print implode("->", $breadcrumb); | |
| 68 | - print "->$message<br />\n"; | |
| 122 | + print implode(" -> ", $breadcrumb); | |
| 123 | + print " -> <strong>" . $this->_htmlEntities($message) . "</strong><br />\n"; | |
| 69 | 124 | } |
| 70 | 125 | |
| 71 | 126 | /** |
| ... | ... | @@ -75,7 +130,8 @@ class KTHtmlReporter extends HtmlReporter { |
| 75 | 130 | */ |
| 76 | 131 | function paintMethodStart($test_name) { |
| 77 | 132 | parent::paintMethodStart($test_name); |
| 78 | - print "<br /><span class=\"method\"><b>Method start:</b> $test_name</span><br />"; | |
| 133 | + if($this->show) print "<br />"; | |
| 134 | + print "<span class=\"method\"><b>Method:</b> $test_name</span><br />"; | |
| 79 | 135 | } |
| 80 | 136 | |
| 81 | 137 | /** | ... | ... |