in reply to Testing: To Mock or Not to Mock?

I mock everything. I even maintain DBD::Mock. The only thing about mocks is that you have to test your tire on a car against the road at some point or another. So, while I have dozens of SQL statements in DBD::Mock sessions, those statements had to come from somewhere and have to be verified against that somewhere when they change.

Remember - a test suite does two things. It allows you to exercise the API while developing (Test-Driven Development) and it verifies that changes don't break previously-working code. Mocks are much better at doing the latter than the former. Use them where they make sense.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?