I'm just starting to work through a copy of Working Effectively with Legacy Code by Michael Feathers. I've had my eye on the book for a while, and am really glad I was able to borrow a copy (now I just need to buy my own). Like any good book it's making me think, making me question things I've taken at face value. So far, the best example of this is in his discussion of Unit Testing.
I've recently been looking more at RSpec and BDD instead of Test::Unit, bu haven't quite caught the vision. Something that Michael wrote made me wonder about it even more. One of the big values of RSpec is that it reduces coupling between tests and code, which sounds really good. Then I read Michael's list of the qualities of good unit tests:
- They run fast.
- They help us localize problems.
At first this seems like it contradicts the aim of reducing coupling (a la RSpec). I can see two possible responses:
- RSpec isn't about unit testing, it's about testing at a higher level — but does this mean we should still have unit tests?
- Specifications and Contexts should be written against specific classes (though not necessarily against specific methods — but doesn't this limit the decoupling we can do?
I'm not sure a completely grok this. Anyone want to weigh in?