4 May 2005 06:11
RE: Mulitthreading & TDD
Charlie Poole <tdd <at> pooleconsulting.com>
2005-05-04 04:11:51 GMT
2005-05-04 04:11:51 GMT
Hi Carlton,
First be sure to unit-test all the pieces - without worrying about
threading.
If you are refering to actual OS processes, then I think you are
definitely in
the domain of application integration testing, not unit testing.
OTOH, if you simply mean individual threads doing a particular job, I
think
it depends on how well you can isolate the thread coordination. For
example,
if you had a queue that is fed from several threads and unloaded by a
single
reader, I think you'd want to
1. Make sure the queue actually works using standard unit-tests
2. Make sure that the results are what you would expect when two or
more writers try to get to the queue.
3. Make sure that writers and readers don't interfere.
You can do that by establishing appropriate locking and setting up
situations
that would cause a conflict if the locking did not work.
If you have several places where this sort of coordination is needed,
then you
should encapsulate it in your own class - or use a builtin one if
appropriate.
In that case, set up a dummy class that allows you to test the required
locking scenarios in the abstract and leave only a few tests in place
(Continue reading)
RSS Feed