2009-11-03

Test-driven Development

The principle of test-driven development is to program the tests before the main application.

The application implementation should start with the "simplest happy path". After this, tests can be part of the development cycle: code, compile, test, execute. Tests are executed in all builds.

Just like compilation errors, test errors should be fixed as soon as they are detected.

And what about errors in the test code? :-)

The test code should be so simple it's obvious it's right.

The test code can be so complicated it's obvious it's wrong.

--

Learn more about this on Nuno Marques's blog.

(em Português)

2 comments:

  1. Miguel the cycle is always

    red -> green -> refactor

    which means:

    write the test, see it fail -> code the implementation, see the test pass -> refactor to remove duplication and improve design

    ReplyDelete
  2. I was trying to quote Tony Hoare:

    http://c2.com/cgi/wiki?TwoWaysToDesign

    ReplyDelete