Alittle Mock Goes Along Way

I believe that one of the most powerful features of MockObjects is that you can reuse them over and over again. When hand coding MockObjects (as opposed to using tools like EasyMock, which I haven't looked into yet), there is usually a fairly big upfront cost involved to set up the code so that it works properly with MockObjects. This usually ends up being very much worth it since the MockObject turns a previously untestable class into a testable one. Any other classes that may depend on a RealObject can now use the MockObject, and they too become testable. Extending a MockObject is usually pretty easy, so you get even more reuse there.

I think this is especially true for MockingLegacyCode. Does anyone else HaveThisPattern?

Yes. When working with a new library, the first few tests can be quite expensive to write. After a while, however, things settle down. I've found that I haven't had to change mock libraries for months after laying down the basics. -- SteveFreeman


CategoryMockObjects


EditText of this page (last edited June 19, 2004) or FindPage with title or text search