Clean Code, Episode 23 part 2

By Uncle Bob

45 minDec 2013

OK, so now you know what OBAFGKMLT means...

This is part 2 of Episode 23 - Mocking. In the previous episode you learned all about the motivation for, and structure of, test doubles.

Now, in part 2 we're going to learn about the never ending struggle between Behavior and State; and the remarkable stress this dichotomy puts on our mocking strategies. This will lead us to: The Uncertainty Principle of TDD and the never ending battle between the Mockists and the Statists.

Then we'll get all pragmatic and start examining some of the most useful mocking patterns such as: Self-Shunt, and Test-Specific Subclass, and my favorite: Humble Object. We'll show you, with lots of code, how and when these patterns should be applied.

Indeed, we'll use the Humble Object pattern to show you how to test GUIs. We get a little Swing UI up and running and then show you how to separate the code so that the testable bits are all isolated from the GUI bits.

And then, to top it all off, we'll talk about Mocking Frameworks. We'll discuss what they are good for, when you might want to use one, and why I don't use them very much.

And that, at long last, will bring us to the close of Episode 23.