How to Test With Multiple Threads
Multi-threading is one of the most difficult aspects of writing software. Something that’s often overlooked is how we can test multiple threads. And can we use TDD to help design software that uses multiple threads? Yes, TDD can help and you’ll find useful and practical guidance in this chapter that will show you how to use TDD with multiple threads.
The main topics in this chapter are as follows:
- Using multiple threads in tests
- Making the logging library thread-safe
- The need to justify multiple threads
- Changing the service return type
- Making multiple service calls
- How to test multiple threads without sleep
- Fixing one last problem detected with logging
First, we’ll examine what problems you’ll find when using multiple threads in your tests. You’ll learn how to use a special helper class in the testing library to simplify the extra steps needed when testing with multiple threads...