improve tests
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Mon, 13 Dec 2004 11:51:43 +0000 (11:51 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:26:38 +0000 (23:26 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-84

htdocs/TESTS/__init__.php
htdocs/TESTS/index.php
htdocs/TESTS/xorg_errors.php
htdocs/TESTS/xorg_user.php

index f8c8ce5..6e52988 100644 (file)
@@ -6,7 +6,8 @@ define('PATH', dirname(__FILE__));
 require_once('unit_tester.php');
 require_once('mock_objects.php');
 require_once('reporter.php');
-
 require_once('xorg.globals.inc.php');
 XorgGlobals::init();
+
+$reporter = new HtmlReporter();
 ?>
index ef6fb19..45e774e 100644 (file)
@@ -4,21 +4,48 @@ require_once("__init__.php");
 require_once('shell_tester.php');
 require_once('mock_objects.php');
 
-class AllTests extends GroupTest {
-    function AllTests() {
-        $this->GroupTest('All tests');
-        foreach (glob(PATH.'/*_*.php') as $tfile) {
-            $this->addTestFile($tfile);
-        }
+class MyReporter extends SimpleReporter {
+    function MyReporter() {
+        HtmlReporter::sendNoCacheHeaders();
+        $this->SimpleReporter();
+    }
+
+    function paintFooter($test_name) {
+        global $tfile;
+        $class = $this->getFailCount() + $this->getExceptionCount() > 0 ?  "red" : "green";
+        print "<div class='$class'>";
+        print "<h1><a href='".basename($tfile)."'>$test_name</a> (";
+        print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
+        print ")</h1>\n";
+        print "<strong>" . $this->getPassCount() . "</strong> passes | ";
+        print "<strong>" . $this->getFailCount() . "</strong> fails | ";
+        print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
+        print "</div>\n";
+        flush();
     }
 }
 
-$test = &new AllTests();
+$reporter = new MyReporter;
+echo <<<EOF
+<html>
+  <head>
+    <title>ALL TESTS</title>
+    <style type="text/css">
+      body { padding: 0px; margin: 0px;}
+      div { float: left; color: white; padding: 1ex; border: 1px dashed white; }
+      h1  { padding: 0px; margin: 0px;  font-size: 120%; }
+      a , a:visited { color: inherit; }
+      .red   { background-color: red; }
+      .green { background-color: green; }
+      
+    </style>
+  </head>
+  <body>
+EOF;
 
-if (SimpleReporter::inCli())
-{
-    exit ($test->run(new TextReporter()) ? 0 : 1);
+foreach (glob(PATH.'/*_*.php') as $tfile) {
+    require_once($tfile);
 }
-$test->run(new HtmlReporter());
 
+print "</body>\n</html>\n";
 ?>
index 524e844..e9cde8d 100644 (file)
@@ -29,5 +29,5 @@ class TestOfXOrgErrors extends UnitTestCase {
 }
 
 $test = &new TestOfXOrgErrors();
-$test->run(new HtmlReporter());
+$test->run($reporter);
 ?>
index 7d76067..6540b12 100644 (file)
@@ -57,5 +57,5 @@ class TestOfXOrgUsers extends UnitTestCase {
 }
 
 $test = &new TestOfXOrgUsers();
-$test->run(new HtmlReporter());
+$test->run($reporter);
 ?>