Testing threading
Warren Postma
wp at tekran.spammenziemichnichtdankeschon.com
Thu Apr 7 10:27:25 EDT 2005
George Sakkis wrote:
> How one goes on testing a threaded program, apart from doing a few
> successful runs and crossing his fingers that it at least follows the
> 'correct 99.9999% of the time' rule ?
If you haven't been in there and stepped through all the code, looked
for a reasonable set of test cases, and tried those test cases, then you
haven't tested! :-)
You test a threaded program the same way you test a non-threaded
program. Thoroughly. Test cases. YOu don't *have* to write unit tests,
but it sure helps. Code running a few times isn't tested. If you
prefer to test manually, really want to be thorough you have to find
ways to make sure you've done coverage of a reasonable set of test
cases. How do I get myself a set of test cases? Personally I like to
walk through my code in a debugger and ask myself "how could this go
wrong?". "What if I pass a huge amount of data in here? How
unresponsive can I find ways to make this thread get?" "If this is a
network communications thread, let's try all the various error
conditions that can happen on a real network.". ...
When I think of an idea on how things could go wrong ("What happens if
the data isn't here or is invalid?"/"Where should I be catching
exceptions and how should I be handling them?")
Regards,
Warren
More information about the Python-list
mailing list