PHP SimpleTest HtmlReporter verbose report pass


PHP SimpleTest HtmlReporter verbose report pass

如何增加SimpleTest的HtmlReporter的详细程度?

有时,除了失败的测试

之外,还可以方便地查看应用程序通过的测试。

给出的输出仍然很丑陋,这就是我格式化输出的方式:

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());
    }
}

好吧,好吧,看来我需要更多的咖啡才能在谷歌;)取得成功

他们实际上在教程中回答了我的问题,只是一个索引很糟糕的问题。

要点是,我们只是扩展了一个HtmlReporter并定义我们的报告功能。他们为什么不把它作为一种选择,它一直让我感到困惑。

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; }';
    }
}