Feel like a geek and get yourself Ema Personal Wiki for Android and Windows

31 August 2009

Fixing the unit tests

In most of the cases, a failing unit test in my projects is a bug in the test and not a bug in the code it tests. It bring into question wether the unittests are worth the effort.

The answer is: YES. The unit tests are worth the effort. Once you created them:
  • You know how the code should be used: the unit test is your documentation
  • you will get a trigger if you change something for another usecase and break the code's original intent because the test will fail after that
  • The alternative is testing the code by starting the application itself, clicking to the right place, and testing the different scenario's. This is a very dull and time-consuming way of testing, and not very thorough. Creating a unit test for testing the code is way faster than the alternative, and the test will behave exactly the same each time you start it.

No comments: