Testdriven development

I have spent the last few weeks using and learning test driven development.

Test driven development means you write a test for your code before you write the actual code. At first it seems like you do more work, but you really gain time from it.

  • You spend more time thinking on how a function/class should work before you write it. If you write the test first and the function prototypes (empty functions) so the test fails, you know when you are done (because the test succeeds)
  • You can run the tests directly after compiling the code when you make some changes, this gives you confidence that your code works!
  • When you find bugs you first try to reproduce them inside the test, and then you correct them inside the code -> Less chance you will run into that bug ever again.
  • When you are forced to write tests your code will be easier to test automatically since you write the code for testing.
  • It is fun to fulfill tests, it feels good!
  • Less manual testing, many manual testcases can be automated, i have rewritten some of my user interface code so it can be automatically tested.
  • You get example code for how to use the class
users avatar

Post new comment

Please solve the math problem above and type in the result. e.g. for 1+1, type 2.
The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <h1> <h2> <h3> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.
  • Images can be added to this post.

More information about formatting options