【发布时间】:2017-02-17 17:58:53
【问题描述】:
当我运行 phpunit 时,我得到:
1) FooTests::testException assert(): 断言“假”失败
我希望在我的情况下得到断言。
class FooTests extends WP_UnitTestCase {
protected $foo;
public function setUp() {
parent::setUp();
$this->foo = new Foo();
}
function testException() {
// I'd like to expect an assert in the class foo so the test should not fail.
$this->foo->test();
}
}
class Foo {
public function __construct(){
}
public function __destruct(){}
public function test(){
assert('false');
}
}
【问题讨论】:
-
该行为是由于以下类型的 phpunit 引发的异常:
PHPUnit_Framework_Error_Warning您使用的是哪个版本的 php?
标签: php unit-testing phpunit