DEV Community

Discussion on: What was your TDD aha moment?

Collapse
 
mahidharc profile image
mahidharc • Edited

I'm a rails developer, and early on I always struggled with the granularity of my tests for a long time. Should I test every method, model, controller, associations, callbacks etc. Then I read the BDD Introduction article by Dan North, and that really helped me understand that it wasn't about trying to test every little line, but rather broader "integration" level tests.

It helped me realise that my service objects should be treated as black boxes whose interfaces are what I tests directly, without worrying about the implementation. And surprisingly when I did follow that approach I found that my code coverage was more that usual, my class design improved, and I also had a lot more confidence in my test suite.