sam*_*ime 4 php phpunit unit-testing
我喜欢偶尔为占位符使用空函数(主要是空构造函数,因为它有助于避免构造函数的意外重复,因为我的团队知道某个地方必须始终有一个构造函数)。
我还喜欢对类的每种方法至少进行一次测试(主要是因为这是一个很好的简单规则,可以让我的团队反对)。
我的问题很简单:我们应该在这些空测试方法中放入什么来防止出现“无测试”警告。
我们可以执行 $this->assertTrue(true) ,我知道这会很好地工作。然而,我想知道是否有任何更官方和正确的东西(最好是一些使得该方法不计入运行的测试数量的东西,人为地夸大了它)。
谢谢。
尝试这个 :
/**
* @covers Controllers\AdminController::authenticate
* @todo Implement testAuthenticate().
*/
public function testAuthenticate()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
Run Code Online (Sandbox Code Playgroud)