Alex Collins - 5 Tips for Unit Testing Threaded Code
5 Tips for Unit Testing Threaded Code
Here's a few tips on how take make testing your code for logical correctness (as opposed to multi-threaded correctness).
I find that there are essentially two stereotypical patterns with threaded code:
- Task orientated - many, short running, homogeneous tasks, often run within the Java 5 executor framework,
- Process orientated - few, long running, heterogeneous tasks, often event based (waiting on notification), or polling (sleeping between cycles), often expressed using a thread or runnable.
Testing either type of code can be hard; the work is done in another thread, and therefore notification of completion can be opaque, or is hidden behind a level of abstraction.
Read full article from Alex Collins - 5 Tips for Unit Testing Threaded Code
No comments:
Post a Comment