Test Driven Development
Hi there, thanks for reading my first post. Since I decided to write in order to improve my understanding of Software Development, and of course, share it with whoever is interested in this area, I could find a perfect subject that I could write about and people also would enjoy it.
The idea of writing about Test Driven Development (TDD) came after talking to my manager about tests in general. After the conversation moved towards TDD, he asked me the following question: “In TDD, should we implemented all tests before their passing code or individual ones before their passing code?”. My understanding of TDD before this question was based on informal discussion and TLDR posts. I couldn’t answer him for sure based strong literature references.
I heard about TDD since my first steps on programming, even though the subject hasn’t cought my attention at first. However, I changed my mind about its importance since I started to learn Clojure and read a post about TDD with Clojure. After the conversation with Manager, I decided to read a reference book to check if what I thought about TDD is really what it was meant to. I am sure there a lot of great books about TDD. Yet I chose the book recommended in Martin Fowler’s blog, Test-Driven Development by Kent Beck, the creator of this technique.
The cycle that I’ve learned was the following:
- Write a test
- Make it pass
- Improve the code
- Repeat
This list seams to be too much simple, yet it somehow shows the essence (maybe it is too summed up) of the technique according to the book. After reading the book, I improved my knowledge about the technique, I decided to use it in my daily work, and I see that my Manager was correct.
Here are the points of the cycle listed in the book:
- Add a small test
- Run all tests and fail
- Make a change in the code
- Run again all tests and pass
- Refactor to remove duplication
Before that you should have a list of test cases and increment it while you continue to implement the tests and the code to pass them.
Thanks again for reading. If you find any error, agree or desagree with what I have written, please let me know.