Unit tests: Are they bad?

testing unittest mocks stubs

02|28|2010

Jay fields wrote a blog post about the maintainability of tests. Basically his takeaways were the following:

  1. You should probably write unit tests
  2. Only focus on the test cases which provides the most business value.
  3. Make tests more concise.

I have been on the other side of the fence, and have gone berserk writing tests for all cases, working hard to increase the coverage of my code. I have even followed the “Unit tests should only access itself, and should only interact with other objects via mocks and stubs” advice. All that led to just more maintainability, so I agree that there is a striking balance to maximize the ROI of your testing efforts.

Most of the data validation parts are important

In order to address maintainability and conciseness while still testing almost all of your validations, we just use macros. An example of this would be:

blog comments powered by Disqus