Accueil > Informatique [computer science] > Fortran > Test Driven Development

Test Driven Development

Test first !

mercredi 27 mars 2013, par Vincent MAGNIN

TDD is appropriate for scientific computing because a computing program is generally composed of a lot of functions whose returned values are well defined and can be easily tested.

  1. Write a unit test.
  2. Be sure that it fails (because you have not yet written the function !).
  3. Write the simplest function that can pass the test.
  4. Refactor the code (improve the design of the code without changing its behaviour).
  5. Go to 1.


- If a test fails, there is a bug (in the code or in the test !)
- If all tests are OK, who knows ?
- Tests are like little experiments that try to falsify the program (cf. Karl Popper).
- TDD is thus a scientific method for programming.
- Writing tests first favours more independent modules.
- And you are sure that most of the code will be covered by tests.