The Small Business Consultancy

Making a Mockery of TDD

Usual weekly update on the activities of the eXtreme Wednesday Club. This week was going to be a short one due to other commitments, well it WAS until I started to write it up!

Mr Roundtrip was fashionably late, as usual one of the last to arrive. The group welcomed a new member Colin Mackay, aka “The Hard Rock Cafe” T-shirt man. Obviously he had been reading the blog entry from last week, and not wanting to have the same stood up look as Jon Mountjoy he describe himself in advance:

“I’ll be the one in the Hard Rock Cafe T-shirt standing at the bar. My colleagues comment on how I always wear these T-shirts!”

Which got me to thinking, I wonder if he has more than one? I guess so. So how many would you need…

One: not enough.
Two: danger of yesterday’s T-shirt not being dry yet after being washed.
Three: just right. One on the back, one in the wash and one drying.

I must ask him how many T-shirts it takes to work on a daily Hard Rock rotation.

The usual introduction done, we got talking about XP and TDD. Colin told us how his team were doing TDD, but on further examination we discovered they are infact only using NUnit for testing: they write the application code and then the tests. We agreed this was an excellent idea for development houses not doing it eXtreme. Better to have an efficient test suite that can be called upon at a moments notice, which can be run time and time again, than relying on developers doing “some form” of testing post-changes.

For those people who know Andy Swan the following tale may be hard reading. There are a number of things in Andy’s value system, on the minus column stands the notion of using Mock Objects in any code, anywhere, at anytime! I’ll need to para-phrase here, but statements Andy is likely to say about them may look something like:

“Most developers just use them as stubs. The Mock Object guys will tell you they are much more! But in most cases they are just stubs.”


“Its the lazy man’s way of doing TDD!”


“Mock objects are a code smell that something else is wrong with your design!”

Having not looked too much at mock objects I’m still undecided. However, Andy and Brian are usually pretty close to the mark. One of their mates, Rich (welcome to Rich), showed up a little later on. Did I hear Andy fumbly apologising for using mock graphic objects or did my ears deceive me? So how did we use them? I’ll try to describe this, but the lack of code on hand may well hamper my feeble attempts. Actually the code may not help me out here! Surely Andy will blog about it. Andy blog about it please!

We watched as Andy created a MockGraphic class that would track graphic (and text) objects drawn on the MindMap canvas e.g. drawing a central idea saw two objects being tracked: a circle (actually make that an arc in Java terms) and some text. The tests would then check that the MockGraphic log contained the expected details about the GUI element. Later on the mock graphic class and its tests can hopefully be replaced with real tests that will actually look at what is happening on the screen. Result, we had some tests for graphics.

Alas, our feelings of elation turned to dismay when it was discovered that resizing the frame resulted in multiple central ideas, but only when resizing the frame to be smaller. Strange! Suggestions flew fast and furious on how to adapt the code to fix this “feature”. I nearly wrote refactor instead of adapt, but it wasn’t refactoring, it was more like controlled hacking. We had a laugh about being nothing more than hacks! [Note to oneself: must remember to revisit the whole topic of XP coding and when it turns to hacking out lines of code]

After a few minutes we abandoned Andy and Rich to figure out the problem, latching onto Brian and his eXactor automated acceptance testing framework. When I say his, I do mean his! He and one other developer from exoftware are working on its development. Even although it is still “under development” it already looks to be very useful. We were all well impressed, especially Abdel who is currently looking for that one panacea that can see the whole concept of XP being adopted within his organisation. Perhaps he has found it. Only time will tell.

It was just about this time that Andy was starting to tidy the laptop away! Hold on one god, damn minute! “Did you get it fixed?”, was the call from me. Oh yeah of little faith, of course he and Rich had figured it out. The resizing problem had been due to using JComponent. Perhaps this is a problem with JComponent? They had replaced JComponent usage with JFrame (or was it something else – only a few hours and already the memories are fading). Kudos again to Andy and to Rich.

Laptops away, we got the chance to chill-out and relax. Talk turned to Agile books worth reading, which led onto a discussion on version control systems.

  • SourceSafe – blah!
  • CVS – mmmm!
  • Subversion – Anyone used it?
  • Perforce – The dog’s bollocks!

Rich gave us the low down on Perforce, which incidently has a two developer free license model. Let me see if I can get this correct:

“It is an atomic transactional VCS systems that allows developers to link to any version, blah, blah, blah!”

Go see their site, it is all there!

We had a wee discussion on how we should use the Wiki, since I don’t want to see it becoming a mess from day one. Abdel did try to impart the notion that this is what they are for, but I negated his line of argument by the following, simple statement:

“But we don’t want to see it just becoming ssspluuurp!”

[It was actually more of a morning after a good curry and a drinking session noise!]

Talk turned once again to one of our favourite blogs, The Bile Blog. Andy informed us of the advice Hani once gave on increasing traffic to your blog. It went something along the lines of take someone or something and take the exact opposite view to what ever the community thinks. Did I mention that we are really lucky to have Andy and Brian as our mentors. They just know so, so much :-) .

We played a game of “trumps” but that’s another story for another posting…. see the next posting.

Abdel attempted to make a few exits over the course of the next hour, but our banter and joviality where just too much of a draw. Almost sure that I heard Abdel saying something along the lines of,

“I keep trying to get out, but they keep PULLING me back in!”

or was that Al Pacino in Godfather III?

Good job done, it was up to Mr Roundtrip to act as chaffeur for Abdel and Colin. Dumped Abdel off in the middle of Stockbridge. Wonder if we can try ejecting him while the car is still moving? This could make it interesting! Maybe we’ll let him get married before try it.

Colin and I then discussed how he had found the evening. Now he is a pretty smart guy, but even his head was hurting attempting to get to grips with the paradigm shift called “eXtreme Programming”. The first steps had been taken down the road to enlightenment and he seemed to have a new glow! We have a new convert my friends, long live the revolution!

This weeks lesson: Mock Objects do have a place and time.

Feel like your missing out? Like to come along? Come on you know you want to! We’d love to see more people coming along.

2 Comments on “Making a Mockery of TDD”