Chapter 13Testing Some Tough Stuff
Not everything is easy in unit testing. Some code will be downright tricky to test. In this chapter we’ll work through a couple of examples of how to test some of the more challenging situations. Specifically, we’ll write tests for code that involves threading and persistence.
In Chapter 10, Using Mock Objects, you learned to simplify testing by breaking difficult dependencies using stubs and mocks. In Chapter 5, FIRST Properties of Good Tests, you saw another example where you broke a dependency on the ever-changing current time (see FI[R]ST: Good Tests Should Be [R]epeatable). You also learned that the design of the code has a lot to do with how easy it is to test.
In this chapter our approach to testing ...