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

  1. Write a failing test
  2. Write the simplest code to pass the test
  3. Refactor your code: remove duplication, rename variables, extract methods...

Tips

  • 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?
Modifié le: dimanche 5 novembre 2017, 20:03