Monthly Archives: September 2014

What to mock and why not to mock data objects?

Recently when reviewing my code before opening a pull request, I have noticed a few methods that I felt were untested. I have run all tests with coverage and indeed 7 methods in the class were not covered. The class was a data object and all these 7 methods were mostly getters and setters so the following questions arose:

  • Should I have a unit test for data object?
  • Should I be testing getters and setters?
  • Why I never had to do this before?

Read the rest of this entry