Geo*_*F67 5 php testing unit-testing correctness
如果您正在测试类似下面的计数函数,那么在一个函数中为函数测试多个东西而不是为每个测试都测试函数,它被认为是"正确"还是"错误"?
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();
}
Run Code Online (Sandbox Code Playgroud)