I have recently been looking at some testscripts which looks a bit like
...
try {
receiveSomething();
// something was received even though it shouldn't
failTest();
} catch (TimeoutException e) {
// nothing should be received
succedTest();
}
The problem I have with these types of tests is
- They are not deterministic. You don't know if nothing was sent on purpose or if everything has crashed.
- Its very hard to simultaneously test something else, which might actually, in this case, send something.
My thoughts are one the one side, how can this types of tests be designed better, and secondly can this be an indication of a bigger design smell of the software that is being tested?
EDIT
To clairify, these test scripts are used for black box-testing of event-based, complex software, not unit testing, and my feeling is that the 'doing nothing' event is a very ambiguous one. :)