22.12.14

"Side effect" of unit tests

Sometimes the test itself doesn't do much. It maybe simply tests something very minor. However, implementing the unit tests will force us to make sense of the code.

Today I tried to create a unit test for a DAO class. I had to keep on refactoring the code until I can write simple test for it:


  • Simple mock object.
  • Easily definition of the purpose in test.
The test itself turned out to be very trivial, but the source code for the business logic make a lot better sense to me and others.

No comments: