Where to Start?

“Where do I start testing?” is one of the most common questions that people have when they start with TDD. Traditionally, my answer is a somewhat glib “start anywhere.” While true, this is less than helpful.

A good option for starting a TDD cycle is to specify the initialization state of the objects or methods under test. Another is the “happy path”—a single representative example of the error-free version of the algorithm. Which starting point you choose depends on how complicated the feature is. In this case it’s sufficiently complex that we will start with the initial state and move to the happy path. As a rule of thumb, if it takes more than a couple of steps to define an instance of the application, I’ll start with initialization ...

Get Rails 4 Test Prescriptions now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.