2

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
4

1 に答える 1