TDD, Where Did it All Go Wrong

Source: TDD, Where Did it All Go Wrong

Author: Ian Cooper

Content

Mocks: first call this twice, then this, and put these parameters on it and return

so a change would break all the mocks. This adds friction to changing code, since you have to fix breaking tests when implementation details change.

duct tape programmer business and product loves this programmer. they just gives solutions as fast as they can.

the rest of the team spends their time trying to fix and maintain the duct tapped code.

if I refactor some code and the test breaks, why did it break? Is it so full of mocks that nothing is actually being tested apart from the mocks.

Is it broken because the behavior changed? Where is that behavior expressed?

Slow tests break flow

the trigger for writing a new test is not adding a new class, its a new requirement.

test public API

The SUT is not a class

the definition of a "unit" is the issue

Do not write tests for implementation details, these change. write tests against the stable contract of the API.

Refactoring is a key step in keeping code healthy.

Only writing tests to cover the implementation details when you need to better understand the refactoring of the simple implementation we start with. (delete these after)

the terminology "behavior" tests confuses people less.

we avoid FS, databases, etc, because these shared fixtures prevent us from in isolation its the isolation of the test and not the isolation of the code under test

in mem db solves this.

tests have to run fast, talking to real dependencies may slow this down.

if there is no shared fixture problem, talk to a DB and the FS

focusing on methods gives tests that are hard to maintain we don't capture behavior we want to preserve we can't refactor easily because the implementation details are exposed to tests.

RED-GREEN-REFACTOR write a failing test duct tape program refactor code, the behavior is asserted by the test

Dependency is the key problem in software Coupling will kill you before DRY

don't make a method public just to test it

how can you refactor if your internals are exposed. refactoring is the process of improving internal structure, without altering external behavior.

Summary

← Incoming Links (1)

Index
wiki • Line 49
"- TDD, Where Did it ..."

→ Outgoing Links (1)

Ian Cooper
wiki • Line 5
"Author: Ian Cooper"