std.unittests vote tally
Daniel Gibson
metalcaedes at gmail.com
Tue Feb 8 09:08:58 PST 2011
Am 08.02.2011 18:00, schrieb spir:
> On 02/08/2011 04:54 PM, Jonathan M Davis wrote:
>> I would point out, however, that it would be rather silly to include
>> assertThrown and not assertNotThrown. Good unit tests should test_both_ that a
>> function succeeds as it's supposed to_and_ that it fails as it's supposed to.
>> So, I would hope that people vote in favor of assertNotThrown.
>
> I do agree failure cases must be tested (maybe even more) and are very often
> neglected by programmers in unittests. But in a no-throw case the proper
> assertion is just a regular assert (at least, in my use of unittests):
> // dunno the syntax
> assertThrown ( 1/0, DivisionByZero );
> assert ( 1/1 == 1 );
> If 1/1 throws DivisionByZero, I get all the information I need. Reason for my
> question mark about including assertNotThrown. When do I need it? What new does
> it bring?
> Sorry, I should have asked/commented earlier on this point (but had too much...).
>
> Denis
Maybe it can be nested like
assertThrown!Exception( assertNotThrown!MyException( fun(42) ) );
to ensure that fun() doesn't throw a MyException, but does throws another Exception?
Cheers,
- Daniel
More information about the Digitalmars-d
mailing list