Most of people hear about this but we force to see that most of people still fail to apply it even if this could be a huge boost for your carrier and projects you are working on.
What is Testing?
All developers test their code to check if it is working as expected so what are we calling testing?
In the mouth of people testing is often linked to automated testing which is a practice where instead of testing yourself a piece of code you wrote, you write another piece of code to test it for you.
This even if it looks fastidious as an avantage, it can be run over and over giving a huge benefits on long term.
This also has three big others avantages:
- The internal logic of the original developper stays with the code and it is possible years later to understand why certain has been made on the design from the code.
- No more need time to test manually as we can run it in background.
- It reduce the cost of a bug allowing to detecting it faster.
However to have theses avantages testing needs to be done right.
To do testing right we need that the people doing the test have no idea about the code written otherwise it will match the code written.
To do that some compagnies hire testers and programmers that does both their part of the code.
However it exists a technique that require only one programmer.
TDD a solution for testing right while being alone
TDD or Test Driven Development is a method of developing that is based on test.
All development should follow this process:
- Write one test.
- Check that test fails.
- Write code and run the tests until it all pass.
- Go back to first step until you finished your feature.
This simple trick solve a big issue in what we saw before: the tester shouldn’t know about the code to write right test. By writting the test before the code, you don’t know yet the future code and you can create the test without being baised by your own code.
This method also have others good points.
The first benefit advanced by people using this method is the gain of time compared to normal programming.
As you only write code to make the test pass you forget all the unecessary parts speeding you up but it also due to the lack of regression during the development as you already specified all your requirement while you developed previous iterations.
In conclusion, TDD is a method to right well created automated tests without the necessity of another person and this is why this skill is appreciated by recruiters.
I hope after reading this article you will get curious about it and maybe start using it in your coding routine.
Leave a Reply