SimpleTest PHP 未完成显示失败的测试器
由于某种原因,即使我设置了一些其他类似的测试并在同一环境中为其他类工作,SimpleTest 也没有运行我的测试函数,但这并不是说这些测试无法运行。我收到的消息是(在绿色成功条中):
FormControllerTest.php
0/1 个测试用例完成:0 个通过,0 个失败,0 个异常。
所以它发现有一个测试用例,但它没有运行它,但它也没有抛出错误。
我已将测试用例简化为尽可能简单的内容,例如:
require_once(dirname(__FILE__) . '/simpletest/autorun.php');
require_once(dirname(__FILE__) . '/../FormController.php');
class FormControllerTest extends UnitTestCase {
function shouldFail() {
$this->assertFalse(true);
}
}
我无法理解为什么这不起作用。有人对为什么它可能不运行我的测试有任何建议吗?
非常感谢
For some reason, even I have some other similar tests set up and working for other classes in the same environment, SimpleTest isn't running my test function, but it's not saying that the tests are unrunnable. The message I get is (in a green success strip):
FormControllerTest.php
0/1 test cases complete: 0 passes, 0 fails and 0 exceptions.
So it has found that there is one test case, but it's not run it, but it's also not throwing an error.
I've reduced the test case to the simplest possible like:
require_once(dirname(__FILE__) . '/simpletest/autorun.php');
require_once(dirname(__FILE__) . '/../FormController.php');
class FormControllerTest extends UnitTestCase {
function shouldFail() {
$this->assertFalse(true);
}
}
I can't understand why this is not working. Does anyone have any suggestions as to why it might not be running my test?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了我的测试功能未运行的原因。
根据 SimpleTest 网站的此页面:
因此,一旦我将上述函数的名称更改为 testShouldFail(),它就会发现并正确地使测试失败。
希望对某人有帮助。
I found the reason that my test function wasn't running.
According to this page from the SimpleTest website:
so, as soon as I changed the name of my above function to
testShouldFail()
it found and correctly failed the test.Hope that helps somebody.
尝试将需求放入类构造函数中。
Try to put the requires inside a class constructor.