我已经开始对我的
PHP程序使用单元测试,并认为Simpletest是一个很好的潜水地点.我将Simpletest文件添加到我的测试服务器,并在我的自定义PDO类上运行以下测试:
require_once('../simpletest/autorun.php');
require_once('../includes/inc_sql.php');
class TestOfSQL extends UnitTestCase{
function testRead(){
...
}
function testWriteAndDelete(){
...
}
}
?>
这一切都很糟糕.我尝试构建一个涉及(到目前为止)测试文件的测试套件,如下所示:
require_once('../simpletest/autorun.php');
class AllTests extends TestSuite {
function __construct(){
parent::__construct();
$this->addFile('inc_sql_test.php');
}
}
这会崩溃并烧伤,我得到以下读数:
Warning: include_once(inc_sql_test.php) [function.include-once]: failed to open stream: No such file or directory in E:\xampp\htdocs\historicMuncie\simpletest\test_case.php on line 382
Warning: include_once() [function.include]: Failed opening 'inc_sql_test.php' for inclusion (include_path='.;E:\xampp\php\PEAR') in E:\xampp\htdocs\historicMuncie\simpletest\test_case.php on line 382
Warning: file_get_contents(inc_sql_test.php) [function.file-get-contents]: failed to open stream: No such file or directory in E:\xampp\htdocs\historicMuncie\simpletest\test_case.php on line 418
all_tests.php
Fail: AllTests -> inc_sql_test.php -> Bad TestSuite [inc_sql_test.php] with error [No runnable test cases in [inc_sql_test.php]]
0/0 test cases complete: 0 passes, 1 fails and 0 exceptions.
我已经玩过包含路径,Web根目录与服务器根表示法 – 想到的任何事情,但没有任何东西允许该测试套件正常运行.有任何想法吗?