[TIP] how to test "impossible" events

Tim Ottinger tottinge at gmail.com
Tue Sep 30 04:19:37 PDT 2008


Andrew Dalke wrote:
> I can, but that's my question.  It seems to take a lot more work to  
> set up automated tests for those not-known-to-exist corner cases than  
> doing the manual tests that just check to see that the "raise  
> AssertionError('something bad happened')"-type  code path doesn't  
> have a typo.
>   
Yes, but it takes much less effort to repeat the automated test.
If you are going to run all the tests many times a day, perhaps
many times an hour, would you rather run the automated test
or the manual one?

For the cases you don't know about, you clearly can't test in any
fashion at all.  When you find out about them, you can create a
test double (mock/fake) that raises the kind of exception that
you would see if it had failed in a weird corner-case-ish kind of
way.  It will help you solve your problem in code (if you test before
fixing) and it will provide regression avoidance.






More information about the testing-in-python mailing list