Day 5 — Makers Academy

Samuel Beckett and TDD, “Waiting for Green”, errors are your friend, a beginner’s look at first week of TDD

Kevin McCarthy
kevins daily makers academy blog
2 min readMar 6, 2016

--

Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.

I like Samuel Beckett a lot. I like this quote an awful lot.*

Now Test Driven Development (TDD) seems on the face of it to share a bit of Beckett’s fondness for the absurd.

Here’s my newbie’s understanding of TDD.

After writing user stories and domain models (another post I promise) you start TDD by writing a test you know will fail (feature_test). Then you write a different test you also know will fail (unit test). Then you write some code fix it just enough that the unit test doesn’t fail for that reason again. Then you might get a chance to actually pass a test but there’s no guarantee. Also the code you’re writing doesn’t do anything for the moment except pass the tests. You wait for feature test to check its functionality as a whole.

At least I think that’s what its about.

TDD is hard. But kind of fun. Here’s how I’ve been tackling it anyway.

Write Feature test

Fail — Error Msg

Write Unit test

Fail — Error Msg

Write some code which does just enough to handle the error message

Fail — Error Msg (hopefully different to last time)

Write little more code which does just the teensiest amount to handle error message

Pass (although sometimes fail)

Refactor!

Rinse and repeat.

The great thing about this is once you’ve written a good test all you do is follow instructions from the error messages you get. I’ve gotten very into doing these micro progressions so will be writing quite a bit about it I think.

*When I was searching for the exact phrasing of the Beckett quote, I also came across his slapping down of University folk (I did not enjoy University)

Dublin university contains the cream of Ireland: Rich and thick.

Also well worth checking out his fascinating friendship with wrestling superstar Andre the giant.

--

--