gpt4 book ai didi

用于空测试的 PHPUnit 占位符

转载 作者:可可西里 更新时间:2023-11-01 01:04:21 27 4
gpt4 key购买 nike

我喜欢偶尔为占位符使用空函数(主要是空构造函数,因为它有助于避免构造函数的意外重复,因为我的团队知道必须始终有一个构造函数)。

我还喜欢对一个类的每个方法至少进行一次测试(主要是因为这是一个很好的简单规则,可以让我的团队反对)。

我的问题很简单:我们应该在这些空的测试方法中放入什么来防止“无测试”警告。

我们可以只做 $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.'
);
}

关于用于空测试的 PHPUnit 占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14615371/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com