TDD Process Smells – The Code
Agile
in a Flash by Jeff Langr and Tim Ottinger (card #52)
> Not failing first
> No green bar in last ten minutes
> Skipping the refactoring
step
> Skipping easy tests
> Skipping hard tests
> Not writing the test first
> Setting code coverage
targets
--
Not
failing first.
It’s tempting to go right for green (passing), but an initial red (failing)
test tells you that the test works.
No
green bar in last ten minutes. You’ re not relying on your tests
anymore if it’s been a while since you’ve seen green. Is it ever a good time to
not know whether you’ve broken something? Take smaller steps.
Skipping
the refactoring step.
It’s a truly bad idea to make a mess “for now” and promise to clean it up in
the mythical “later” (Robert Martin has addressed this fallacy in his many
keynote addresses).
Skipping
easy tests.
You won’t save much time by not testing simple code, and you’ll possibly create
silly mistakes that go undetected in the code.
Skipping
hard tests.
Difficulty in testing drives us to reconsider and improve our design (to
something that is also easier to test!).
Not
writing the test first. TDD requires you to drive your code changes from
the outside. Writing tests later makes code harder to test and hard to refactor
for testing.
Setting
code coverage targets.
This is a well-understood failure because of the Hawthorne Effect (roughly,
“you get what you measure”). It is better to discourage artificial inflation
(gaming) of metrics.
--
“I have not failed, I’ve just
found 1000 ways that won’t work.” ― Thomas Edison
~ Remember failure is necessary before people can understand success.
No comments:
Post a Comment