[dev] [commits] Horde branch master updated. 474895f80a889d60dd40536cbcc35e6c14d1a732

Michael M Slusarz slusarz at horde.org
Fri Feb 3 22:01:28 UTC 2012


Quoting Jan Schneider <jan at horde.org>:

>>    This is stupid: PHPUnit won't allow expecting a plain old 'Exception'
>>    exception.  Which just seems like blatant broken behavior to me.  There
>>    are several built-in PHP classes that throw Exception natively (e.g.
>>    DateTime), so you can't explicitly check for errors. Dumb.
>
> I guess the idea with expectedException might not be to test whether  
> an exception occurred, but but to test that the correct exception  
> occurred. Testing for "Exception" wouldn't make sense in this  
> context because that would match any exception.

But that's what expectedException is supposed to check for, at least  
according to the documentation.  i.e. if you are expecting an  
Exception, but an Extended_Exception is thrown, that *won't* be caught  
because it is not an exception.

This is not a try/catch() block where we are trying to prevent  
exceptions bubbling to the main .  Which makes complete sense when  
writing test units.  I create a test scenario where I know that an  
Exception_Foo exception will be thrown.  What if there is an issue in  
the code where an Exception_Foo_Extended exception is thrown.  That is  
not the expected behavior, and should not be caught.

michael


___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the dev mailing list