TDD (Test Driven Development)
Le test-driven development (TDD) est une technique de développement de logiciel qui préconise d'écrire les tests unitaires avant d'écrire le code source d'un logiciel. (source: Wikipédia)
In a nutshell
- Write a failing test
- Write the simplest code to pass the test
- Refactor your code: remove duplication, rename variables, extract methods...
- When writing a test, write the assertion first and work backwards.
- Always run the test to see it fail in the way that you expect it to fail before writing the application code to make the test pass.
- Write meaningful tests that are self-explanatory. That is, the names of variables and methods should communicate your intention. I write all of my code now (test and application) thinking of the "Reader" - the person who is reading my code. Will my intention now be clearly communicated to that reader some time in the future?
Last modified: Sunday, 5 November 2017, 8:03 PM