|
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
|
Post new comment