Question

How could I increase the verbosity of SimpleTest's HtmlReporter?

It is sometimes convenient to see which tests the application passes, in addition to the ones it fails.

Was it helpful?

Solution 2

Ok, well, it seems I needed more coffee in order to succeed at Google ;)

They actually answered my questions in a tutorial, just a badly indexed one.

The gist is that we simply extend a HtmlReporter and define our reporting function. Why didn't they make it an option, it keeps baffling me.

http://simpletest.org/en/display_subclass_tutorial.html

class ShowPasses extends HtmlReporter {

    function paintPass($message) {
        parent::paintPass($message);
        print "<span class=\"pass\">Pass</span>: ";
        $breadcrumb = $this->getTestList();
        array_shift($breadcrumb);
        print implode("->", $breadcrumb);
        print "->$message<br />\n";
    }

    protected function getCss() {
        return parent::getCss() . ' .pass { color: green; }';
    }
}

OTHER TIPS

The output given is still quite ugly, this is how I formatted the output:

class ShowPasses extends HtmlReporter {
    var $tests = array();

    function paintPass($message) {
        parent::paintPass($message);
        $pass =  "<span class=\"pass\">Pass</span>: ";
        $breadcrumb = $this->getTestList();
        array_shift($breadcrumb);
        if(!in_array($breadcrumb[1],$this->tests))
        {
            echo "<h2><u>".$breadcrumb[1]."</u><h2>";
            $this->tests[] = $breadcrumb[1];
        }
        echo "<h4>$pass".$breadcrumb[2]."</h4>";
    }

    function _getCss() {
        return parent::_getCss() . ' .pass { color: green; }';
    }
}

class AllTests extends TestSuite {
    function AllTests() {
        $this->TestSuite('All tests');
        $this->addFile(dirname(__FILE__).'/testRequest.php');
        $this->addFile(dirname(__FILE__).'/testTraductor.php');
        $this->addFile(dirname(__FILE__).'/testReservar.php');

        //para poder usar por consola
        //$this->run(new TextReporter());
        $this->run(new ShowPasses());
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top