Comment on Testing on High: Bottom-up versus Top-down Test-driven Development by Ryan Kinderman

Mon, 19 Nov 2007 06:23:48 -0800

They all said they did TDD. As for relentless refactoring, let's just say that I was trying to ask leading questions in that direction, to see if they'd go there themselves. I did, however, generally end up talking about refactoring in some capacity with each dev.

When you say "go back and implement," are you going back to your tests and replacing mocks with the real objects?

No, I mean that you end up with mocks in your tests that represent yet-to-be-developed components in your application. These yet-to-be-developed components have to be implemented before something like an integration test of the functionality passes, which would prove out a particular aspect of a user feature from end-to-end. In other words, the feature being developed just will not actually work until the functionality that is mocked or stubbed is implemented. Does that make sense? Perhaps I should clarify the original statement.

Do you use tools like RSpec or ZenTest to separate your tests for each component layer?

I definitely use and love RSpec. As for ZenTest, I used it in its early stages, when most of what it did was automate running tests, and sometimes had problems doing that. It does a lot more these days, and it might be worth a try.

As for separating my tests for each component layer: with Rails development, I find that I usually have my unit tests broken out into controllers, helpers, libs, mailers, models, services, and such. I don't necessarily clearly define the layers that these categories of components fall into, since the idea of layers, while useful at a high level (model/view/controller), can become transient when a developer tries to define them in more detail. I prefer to keep them rough, and then simply pay attention to having proper interactions between components.

I've been using a combination of Rails integration tests and Selenium to perform integration testing for the systems I build.