Re: Re: PHP Annotations RFC + Patch
| From: | Ralph Schindler | Date: | Thu, 16 Sep 2010 20:11:28 +0000 |
| Subject: | Re: Re: PHP Annotations RFC + Patch | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49731@lists.php.net to get a copy of this message | ||
I know this is drive-by/chiming in, but we've had this discussion with the ZF community. While @expectedExcpetion is a feature of PHPUnit that has been picked up and used by developers over the past few years, it semantically makes no sense, and we have since outlawed its usage.
Why? B/c a "comment" is now affecting the outcome/execution of a code block (in this case a unit test), ... particularly the way the PHPUnit system interprets the outcome of this code block.
We've since removed all @expectedException "annotations" in favor of $this->setExpectedException() call and try/catch blocks for more specific usage. It just semantically makes more sense to our group of developers.
On the other hand, we DO utilize the @group annotation in PHPUnit b/c it does a fantastic job of grouping tests together. Case in point, @group does not ever affect the running outcome of tests.
app. Example:
class FakeTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException RuntimeException
*/
public function testShouldThrowException()
{
throw new \RuntimeException('FakeTest failed.');
}
}