Feel the Pain for Mock Frameworks

Mock frameworks can generate an ‘aha’ moment if you introduce them at the right moment. The evolution looks like this:

  1. Introduce unit testing as a concept.
  2. Walk through the basics of an xUnit framework.
  3. Introduce test driven development.
  4. Introduce fake objects or hand rolled stubs to substitute for things like DAOs.
  5. Use specialized mock object libraries like Shale mock JSF framework to build fake FacesContexts.
  6. Spring EasyMock or JMock on them to handle some nasty edge cases.

We choose EasyMock. Introducing it right up front would have been cognitive overload. Getting TDD installed is really more a journey than a simple prescriptive plan. TDD is about changing a core developer behavior in how they write code. So I saved the mock framework explanation for that moment where it elegantly solved the problem at hand.

3 responses to “Feel the Pain for Mock Frameworks”

  1. Aaron Korver says:

    The best time to introduce something new is when there is a pain. People are more inclined to listen when they know they hurt, than when they feel good.

  2. Ed Gibbs says:

    When they feel good they explain how they can just deploy it and debug it on the server, no need to write the stinkin’ tests.