TDD was my biggest aha-moment, it was mind-changing.
In the past, I used to do big up-front detailed design. Given some requirements, I would try to come up with the most optimal design up front. The issue was, sometimes this resulted in over-thinking, and over-engineering, and it took time to get to a working solution.
So then I moved onto a more “sliced” approach, doing just enough design to satisfy the primary flow, and then doing the alternative flows. At least this resulted in getting the code working sooner, but there was still a lot of up-front design, and a long feedback loop. When things didn’t work out, I had to do a lot of debugging, also manual testing, and finally, I wrote the test at the end.
❌ The problems I faced with Test Last were:
I was working in big batches, having long feedback loops, and a lot of debugging when something didn’t work
I designed solutions that were over-engineered, overly abstract, more than needed to solve the problem at hand
I wasn’t really getting the benefit of tests, because I’d write them at the end, run them once, and prior to that it would just be manual debugging
Discovering TDD was the aha-moment, especially reading Kent Beck’s book Test Driven Development: By Example.
✅ I found TDD solved my problems:
Test Driven: I gained the benefits of tests during development rather than at the end of a feature. The tests protected me against regression bugs, so I felt safe moving fast. TDD felt natural, I would start with an executable specification, and then write code to satisfy that specification.
Incremental: I didn’t have to solve the whole problem all at once. I would take a User Story and think of it in very thin functional slices so that I could implement it incrementally. TDD enabled me to start with the simplest behavior and then incrementally expand upon it.
Iterative: I could iteratively refine my design throughout development. I didn’t have to try to come up with the most ideal design right at the start. Rather, I’d do just enough design to satisfy a behavior. Then, over time, I’d be able to iteratively adapt the design. TDD enabled me to refactor safely.
Want to apply TDD in practice?
You tried TDD, but it didn’t work. That's why I'm going to help you practice TDD step-by-step. Apply TDD on a sandbox project, and get my feedback and answers to your questions. Access TDD in Legacy Code.
Thanks for sharing your journey, TDD is something you arrive at through trial and error.