[TIP] how to test "impossible" events
Tim Ottinger
tottinge at gmail.com
Tue Sep 30 04:23:39 PDT 2008
Andrew Dalke wrote:
> Perhaps I can rephrase my question. I know how to write mock systems
> for all of the things I've talked about. the question I've been
> thinking about as I write this code is the trade-off between:
>
> - do I write code to test for cases that aren't known to occur,
> based on experience that other similar code has done unexpected
> things during rare circumstances?
>
Maybe. If you think they're important cases.
> - if so, do I test the code paths?
If you test before coding, you can't possibly do code paths. If you test
last, I suppose you can. It is really like insurance; you should have all
the coverage you need: it's just hard to be sure how much you need.
> Should I
>
> - do manual tests that the code path executed suffice?
>
Once. To see how it works. Then never again.
> - or should I automate those tests?
>
Yes.
> - How much time should I spend setting up mock tests for
> something that isn't known to ever occur?
>
Insurance: as much as you honestly believe you need. If you're short,
you'll
*maybe* pay for more later. If you're long, then you'll never have
that time
back again.
I would say to keep testing and develop that sense of "enough". But never
plan to repeat manual tests. It's a losing game.
More information about the testing-in-python
mailing list