Ep 19, p1 Refactoring under red

134 views
Skip to first unread message

Per Lundholm

unread,
Sep 1, 2013, 10:16:28 AM9/1/13
to clean-code...@googlegroups.com
Hi

Firstly, to Uncle Bob, I want to say I am honoured that you use the TDD tetrahedron to illustrate the red-green-refactor cycle. Clear bragging value for me! :)

Secondly, I may be late to the party, but at the end of the part 1 of episode 19, Bob asked for us to point out mistakes he has made. I believe I spotted him doing refactoring under red, that is, doing refactoring while having a failing test. 

You will run into this frequently when you TDD. You add a test and discover that you are in a dead end with your current design. You realize that a refactor would open a way. However, before you start refactoring, all your test should be green so that you know that you don't break anything. So what to do with that new, failing test that helped you discover the need for refactoring?

You use the @Ignore annotation! That way you can refactor without being annoyed by test failing and still keep it. It will show up in your IDE as ignored and as soon as the refactoring is done, you remove the annotation and continue with implementation.

This is also the only time you can use the annotation *. Having ignored tests lying around is not clean coding.

Regards
  Per
*) Well, it turned out that there is at least one more case. See comments to this blog post: http://blog.crisp.se/2013/07/21/perlundholm/the-proper-use-of-ignore-in-unit-testing

Uncle Bob

unread,
Sep 4, 2013, 11:47:50 AM9/4/13
to clean-code...@googlegroups.com
Welcome aboard Per!  And thank you for the "Crisp" tetrahedron.  It's sitting on my desk right now.  The next time I'm in Stockholm I'll pick up a few more.
Reply all
Reply to author
Forward
0 new messages