On today´s post, we are going to talk about another way of development which kind of goes backwards, this is Test Driven Development (TDD). Test Driven Development consists of writing the tests first, then writing the source code that passes the test successfully and finally refactoring the written code. This methodology sounds kind of atypical, but with this type of practices you actually get a more robust, safer, and more maintainable code with faster development.
TDD was created by Kent Beck (who also invented Extreme Programming and JUnit), and in essence, it is a process to follow, which already makes it different from a simple testing approach. Something really important to point out is that TDD is not for testing primarily, rather a practice that involves development as a whole, especially in software design.
How do you do it?
if you combine the software process design with TDD and agile methodologies, here are the steps to follow:
- The client writes his user story.
- The acceptance criteria of this story are written together with the client, breaking them down to simplify them as much as possible.
- The simplest acceptance criteria is chosen and translated into a unit test.
- It is checked that this test fails.
- The code that passes the test is written.
- Se ejecutan todas las pruebas automatizadas.
- The code is refactored and cleaned.
- All automated tests are passed again to verify that everything is still working.
- We return to step 3 with the missing acceptance criteria and repeat the cycle again and again until our application is complete.
(The pure steps for TDD are 3,4,5,6,7,8,9)
Test driven development can be defined as a test oriented design cycle where you create software in relation with the minimal requirements guided by tests that ensures a functional system as well as robust code in short time.