如果您正在测试如下所示的计数函数,那么在一个函数中测试该函数的多项内容与为每个测试使用一个测试函数相比,是否被认为是“正确”或“错误”?
function testGetKeywordCount() {
$tester = $this -> getDatabaseTester($this -> CompleteDataFile);
$tester -> onSetUp();
$KeywordID = 0;
$this -> setExpectedException('InvalidArgumentException');
$this -> keyword -> getKeywordCount($KeywordID,'Active');
$KeywordID = 1;
$this -> setExpectedException('InvalidArgumentException');
$this -> keyword -> getKeywordCount($KeywordID,'InvalidStatus');
$this -> assertEquals(1, $this -> keyword -> getKeywordCount($KeywordID,'Active'));
$tester -> onTearDown();
}
您应该有多个测试函数,每个函数都测试自己的条件。这样,无需调试就可以更轻松地发现故障。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)