SimpleTestPHP单元测试框架
SimpleTest 是一个为PHP程序提供的单元测试的框架,包含一个内嵌的web浏览器用来测试PHP的Web网站。
示例代码
<?php
require_once('simpletest/unit_tester.php');
require_once('simpletest/reporter.php');
require_once('../classes/log.php');
class TestOfLogging extends UnitTestCase {
function testCreatingNewFile() {
@unlink('/temp/test.log');
$log = new Log('/temp/test.log');
$this->assertFalse(file_exists('/temp/test.log'));
$log->message('Should write this to a file');
$this->assertTrue(file_exists('/temp/test.log'));
}
}
$test = &new TestOfLogging();
$test->run(new HtmlReporter());
?>
评论