{"action":"opened","issue":{"number":40,"created_at":"2011-10-09T14:18:11Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Scope of Change\n====\nThe unittest API should be extended to support some of the annotation \nbased features that will be introduces with JUnit 4.0.\n\nThese annotations include\n  . @expect\n  . @timeout\n\nRationale\n====\nSometimes one might not want to check for certain return values. Issueing\nexceptions to check error handling code is even quite common. \nThe annotation `@expect` will simplify the common case where one needs to\ncheck that a specific exception has been thrown.\n\nThe annotation @timeout can be used to check the runtime behaviour of\na method.\n\nFunctionality\n====\nThe @expect annotation takes the name of the expected exception:\n\n```php\n<?php\n  #[@test, @expect('lang.IllegalArgumentException')]\n  function testMyFault() {\n    $object= &new MyExceptionThrowingClass();\n    $object->throwExpectedException();\n  }\n?>\n```\n\nThe @timeout annotation takes the amount of seconds a method may take\nto execute.\n\n```php\n<?php\n  #[@test, @timeout(13)]\n  function testTimeout() {\n    // Call lengthy method\n    lengthyMethod();\n  }\n?>\n```\n\nThe method will be interrupted if it didn't complete within the time\nspecified and the result will be assumed as failed.\n\nSecurity considerations\n====\nn/a\n\nSpeed impact\n====\nOf course, exception handling is a slow thing, but this doesn't count\nfor unit testing.\n\nDependencies\n====\n- ext/pcntl for the timeout thing\n  http://php3.de/pcntl_alarm\n\nRelated documents\n====\n- JUnit 4 overview\n  http://www.beust.com/weblog/archives/000292.html\n\n- JUnit 4.0 (german)\n  http://www.frankwestphal.de/JUnit4.0.html\n\n- Patch against util.profiling.unittest.TestCase\n  http://xp-framework.net/downloads/rfc0032.diff\n\n- XP Unit testing introduction\n  http://xp-framework.info/xml/xp.en_US/news/view?67\n\nComments\n====\n- testing timeouts seems a bit vague - runtime behavior may be affected by\n  a whole lot of things. Maybe we have no application for this, then.\n  kiesel, Wed Jul 20 00:51:35 CEST 2005\n\n- the resolution of pcntl_alarm is seconds - this may be too much for \n  fine-grained checks. If one can live without the method being interrupted\n  but only profiled for its execution time, the resolution can be increased.\n  Then, again, the question is if there aren't too many external influences\n  for this.\n  JUnit 4's @timeout annotation specifies the timeout in milliseconds.\n  kiesel, Wed Jul 20 00:53:19 CEST 2005\n\n- the attached patch implements the @expect attribute; it does not implement\n  the timeout as I personally think that it is not of use enough. Someone\n  may come up with another patch or convince me:)\n  The @expect attribute has also been changed to take the fully qualified\n  classname of the exception class.\n  kiesel, Sun Aug 21 12:17:27 CEST 2005\n\n- The @expect annotation was implemented. If @timeout makes sense (and \n  because it doesn't work under Windows) we can implement it later.\n  friebe, Thu Sep  1 10:40:45 CEST 2005\n\n<EOF>\n","comments":0,"title":"RFC 0032: Add annotations for Unittest API","updated_at":"2011-10-09T14:18:11Z","url":"https://api.github.com/repos/thekid/rfc/issues/40","id":1856245,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/26f07e3b262e9a80436f368cb11bd0c2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/thekid","id":696742,"login":"thekid"},"html_url":"https://github.com/thekid/rfc/issues/40","labels":[],"state":"open"},"legacy":{"number":40,"action":"opened","issue":1856245}}