I now understand why writing functional tests or unit test for code is so important.  I have taken a course that included some test-driven development and assignments that required unit tests.  Intellectually I have understood the value of these tests, but I never really saw the full benefits of writing tests (although I’m sure I still don’t fully understand).

This week at work one of my big tasks was to write tests for a library that had been written previously and is now being used in a system my team is developing.  In writing these tests, I have been able to learn several things about the library:

  1. How the code works, and what it is supposed to do
  2. The database that the code was written for is not the same one we are using
  3. The library was missing several key functions

If I hadn’t written test for this library, I would still have been in the dark about how it was doing what it was doing (even though I had written a web service that called all the library functions).  I definitely wouldn’t have realized that it was missing features, and I definitely wouldn’t have known why it wouldn’t have worked with our current database.  So, I saved myself and my team plenty of head scratching by writing tests.  Who would have thought test would save time?