BDD / TDD criticized

,

DevTernity 2017: Ian Cooper - TDD, Where Did It All Go Wrong

I find this talk isn’t defending TDD/BDD as it is commonly practiced. Yet it goes back to “the sources” (Test Driven Development: By Example (2002), Refactoring: Improving the Design of Existing Code (1999), Refactoring to Patterns (2005)) to discover the actual intent behind the original practices. In my opinion it ends up in a place aligned with Mocks and explicit contracts.

TLDNR: Test the behaviour of the “public API” - not the implementation details

It concludes with:

  • The reason to test is a new behaviour, not a method on a class
  • Write dirty code to get green, then refactor
  • No new tests for refactored internals and privates (methods, classes)
  • Both Develop and Accept against tests written on a port
  • Add Integration test for coverage of ports to adapters
  • Add system tests for end-to-end confidence
  • Don’t mock internals, privates, or adapters

He does emphasize that when tests are used to discover a suitable implementation, those tests will have to be deleted in the end as they are coupled to the implementation details .

He uses the term Duct Tape Programmer quite a bit.

He also references the Fowler, Beck, DHH conversations on Is TDD Dead?.

5 Likes