我正在使用 PHPUNIT 3.4.5,我想获得我的测试完成的断言总数(我的示例代码的 3 个断言)。方法“getNumAssertions”一直返回 0。
public function test_DateUtil()
{
echo "\nNumAssertions : " . $this->getNumAssertions() . "\n";
$this->assertEquals(1, 1);
echo "NumAssertions : " . $this->getNumAssertions() . "\n";
}
public function test_DateUtil_2()
{
echo "\nNumAssertions : " . $this->getNumAssertions() . "\n";
$this->assertEquals(1, 1);
$this->assertEquals(1, 1);
echo "NumAssertions : " . $this->getNumAssertions() . "\n";
}
}
PHPUnit 返回:
phpunit --configuration phpunit_dev.xml --verbose
PHPUnit 3.4.5 by Sebastian Bergmann.
UtilTest
NumAssertions : 0
NumAssertions : 0
.
NumAssertions : 0
NumAssertions : 0
.
Time: 1 second, Memory: 13.50Mb
OK (2 tests, 3 assertions) ------------> what i want to get