I’ve been hearing about the London style vs. Chicago style (sometimes called Detroit style) of Test Driven Development (TDD).
Workshop of Utah Extreme Programming User's Group:
Interaction-style TDD is also called mockist-style, or London-style after London's Extreme Tuesday club where it became popular. It is usually contrasted with Detroit-style or classic TDD which is more state-based.
The workshop covers both the Chicago school of TDD (state-based behaviour testing and triangulation), and the London school, which focuses more on interaction testing, mocking and end-to-end TDD, with particular emphasis on Responsibility-Driven Design and the Tell, Don't Ask approach to OO recently re-popularized by Steve Freeman's and Nat Pryce's excellent Growing Object-Oriented Software Guided By Tests book.
The post Classic TDD or "London School"? by Jason Gorman was helpful, but his examples confused me, because he uses two different examples instead of one example with both approaches. What are the differences? When do you use each style?
If the important thing is determining that something has or has not changed based on the action being taken (e.g., the ledger.bucket.value becoming 35 when ledger.calculate("5 * 7") is called), you want to use assertions of state (Chicago school). This is most helpful when you have full control over the state of the system before the method is called, and when you actually control what the method does.
– Matthew Flynn Dec 07 '11 at 20:05Calculatorregresses inmultiply, you'll see two tests fail: the ledger test, and the calculator test, but only one test fails if you mock out the calculator. That might make it easier to pinpoint the origin of the bug, especially if the system is complex. – mxk Jan 13 '16 at 10:33