Presentation at XP Toronto

At the March XP Toronto meeting, Jason Cheong-Kee-You and I gave this presentation, Struggling to Create Maintainable Unit Tests?

At the start of the presentation we asked our audience if they where using:

  • a unit testing framework
  • any Mock Object framework
  • Test Data Builders

We also asked if they had read xUnit Test Patterns.

It turned out that essentially everyone was using a unit testing framework and most everyone in the audience had had some exposure to a mocking framework. Very few people had read xUnit Test Patterns. No one was sure about Test Data Builders.

It was the perfect audience for our presentation.

The takeaway from our presentation is that you need to use mock objects with Test Data Builders if you want to create maintainable unit tests. Use mock objects when protocol is important and use Test Data Builders when data is important.

Here is our call to action:

  • read xUnit Test Patterns
  • read Nat Pryce’s blog postings on Test Data Builders
  • learn to distinguish between depended-on components that are essentially protocol versus those that are essentially data
  • try using mock object with Test Data Builders.


AnonymousMarch 27th, 2009 at 2:51 am

What mocking framework do you recommend using?

Typemock or Rhino ?

Alistair McKinnellApril 1st, 2009 at 8:37 pm

I’m not qualified to make a recommendation between Typemock and Rhino Mocks. For the last few years I have been living in Java-land rather than .Net-land.

In Java-land I played very briefly with EasyMock and with jMock. They’re clearly not the same, but they seemed equally capable. I chose one so that I could become an expert user of that tool. In my case, I chose jMock.

So I guess my recommendation to you is to take a brief look at Typemock and Rhino Mocks, pick one, and become a expert with the one you pick.

YehoramFebruary 17th, 2010 at 12:35 pm

A new mini-framework makes it easier to create test data builders –

I haven't used it in a project yet – looks like it is worth a try.

Leave a comment

Your comment