Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TDD Styles

TDD Styles

State Verification versus Behaviour Verification.
Discovery Testing.

Stefan Scheidt

July 08, 2019
Tweet

More Decks by Stefan Scheidt

Other Decks in Programming

Transcript

  1. TDD Primer • Write a failing unit test • Make

    the test pass • Refactor • Repeat
  2. Stubbing and Mocking • Stub: providing "indirect input" • Stubbing:

    Configure a Stub • Mock: allows observation of "indirect output" • Mocking: describing mandatory interactions (Spock) See also Wikipedia
  3. State Verification • "Classic TDD", "Detroit-School TDD" • mostly bottom-up

    / inside-out • uses stubs, but avoids mocking • design emerges through frequent iterative refactoring See Testdoubles Notes on Testing
  4. Behavior Verification • "Mockists TDD", "London-School TDD" • mostly top-down

    / outside-in • uses mocking intensively • design emerges through iterating on the interaction between collaborators See Testdoubles Notes on Testing and Mocks Aren't Stubs
  5. Discovery Testing Defined by Justin Searls 1. Start by identifying

    an entry point and write a collaboration test 2. For each dependency the first collaboration test identifies: a. if it needs to be broken down, write another collaboration test b. if its task is "logic", implement it with classic TDD c. if it interacts with third-party, implement a wrapper object
  6. Discovery Testing In Discovery Testing, objects are either one of

    • "Collaborators", tested with Mocks • "Logic Leaf Nodes", tested with classic TDD • "Wrapper", tested with integration tests • Value Objects passed as arguments and return values