Test Process

Clean Code, Episode 22

By Uncle Bob

83 minOct 2013

Have you ever heard of: Fake It Till You Make It? How about: Assert First or Test Triangulation? These are just some of the test writing techniques that we'll cover in this episode -- and cover with lots and lots of code.

Then we'll face the ultimate existential question of tests: What's more important, the tests or the production code? Indeed, we'll pose it a problem of two disk drives; one containing the tests and the other containing the production code. One of them has crashed. Which do you hope it is?

How much of your refactoring effort should be spent refactoring the tests? Any? And if you do refactor the tests, what is the goal of that refactoring? What does a good clean test look like?

Kent Beck often says: "First make it work. Then make it right. Then make is fast and small."

Ron Jefferies' rules of Simple Design tell us that the code should:

  1. Pass all the tests.
  2. Have no duplication
  3. Express everything the author wants expressed.
  4. Have a minimum of classes and methods

What do these rules have to do with tests? Should they be followed when writing tests? Or is there a different set of rules for tests? The answer may surprise you.

Finally, we'll talk about the term: Test First, and find out what it really means.

So get ready to read lots of code, to think lots of thoughts, and to face the ultimate truth of test driven development.