3. Juni 2013
Sometimes its not enough to write an assertion and "test" it with using it in one of your tests. I wrote the webforge/testplate and therefore find it very useful to test assertions.
If you know some interna from PHPUnit its very easy to accomplish:
public function testIsAssertingExistance() {
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$this->getFile('non-existing');
}
For some forward compability you should refactor the PHPUnit_Framework_ExpectationFailedException
reference with something more flexible, so that you don't have to grep for all your assertions tests when the name of the exception is changed in PHPUnit:
public function testIsAssertingExistance() {
$this->expectedFailingAssertion();
$this->getFile('non-existing');
}
// but this into one of your base TestCases
protected function expectedFailingAssertion() {
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
}
I had the same problems writing my testplate in js with qunit-assert. Unfortunately this is VERY difficult todo in QUnit I would be very glad if someone could point me into the right direction.