Thursday, July 17, 2008

Automated Unit Tests in my life - Part 4


Test Driven Development and Automated Tests advantages


Later I tried to figure out what can be improved by coding in a “new style”.
So these are some of my conclusions:
1) When you develop with tests first, you are building a base for your code:
First you add tests, then add code – so all of the code I added was minimum code, required.
That’s how we create “clean” code.
2) Then you add new test for additional functionality and write code in order to pass the tests
3) Since that foundation is always in place, it lets you modify or re-factor the implementation that built on top without having to worry about breaking some piece of functionality.
4) Let’s say I wrote tests that checks my class various situations. So if I forgot what the code does or someone new joins the team, it is easy to read through a fixture for any class and immediately know how that class will behave in various situations.
5) If I forget if a method is supposed to throw or return false or etc…, a quick scan of unit tests will provide the answer.
6) Since the tests are part of my workflow, they’re always kept up-to-date. And … the system gives you self confidence.

No comments: