【发布时间】:2013-03-04 15:46:03
【问题描述】:
这是我的两个测试用例:
<?php
require_once(dirname(__FILE__) . '/../simpletest/unit_tester.php');
class Tests extends UnitTestCase {
function test_1() {
$this->assertTrue(true);
}
function test_2() {
$this->assertTrue(true);
}
}
?>
和我的测试司机:
<?php
require_once(dirname(__FILE__) . '/../simpletest/simpletest.php');
$test = new TestSuite();
$test->addFile(dirname(__FILE__) . '/ex1.php');
$test->run(new TextReporter());
?>
我得到这个输出:
TestSuite
OK
Test cases run: 1/2, Passes: 2, Failures: 0, Exceptions: 0
当我像这样从终端运行驱动程序文件(ex2.php)时:
curl 'http://localhost/~marc/simpletestexample/ex2.php'
现在,为什么它报告“测试用例运行:1/2”而不是“测试用例运行:1/1”?似乎有一个幻影测试用例没有运行。
【问题讨论】:
-
似乎是一个不同的问题。我将我的课程测试更改为 MyTests,结果完全相同。在我的情况下,问题不在于我的测试没有运行,而是似乎有一个不是我的情况没有运行。
-
@CanGeliş 这与您提供链接的问题不同。无论我们做什么都会发生这种情况,但它仍然显示 1/2。您提供的链接,用户没有使用 test 正确启动函数名称。
-
我无法重现报告的问题:“测试用例运行:1/1,通过:2,失败:0,异常:0”。如果此错误仍然存在,请从 github.com/simpletest/simpletest 获取更高版本的 SimpleTest。如果您遇到问题,请随时在此处打开错误报告。
标签: php unit-testing simpletest