Spies vs. Mocks

This is an eye-opening article about the different type of objects you can use in testing. I’ve been making good progress lately with mock objects. But I readily admit that my tests are way more rigid and brittle than I’m happy with. Unfortunately (well, fortunately for me) I’ve been hearing about it second hand from my coworkers — that my tests break and are a pain in the ass to fix.

Note I say “coworkers” and not “friends”.

Here are a couple of good articles about the whys:

http://hamletdarcy.blogspot.com/2007/10/mocks-and-stubs-arent-spies.html

http://xunitpatterns.com/Test%20Double.html

http://monkeyisland.pl/2008/04/26/asking-and-telling

I’ve been enjoying MockEasy because it’s just neat technology, and I found the interface to be super intuitive and easy. But I worked with mockito today, and found the failure reporting to be a lot clearer and easier to fix when something goes wrong. I might switch over to mockito, because it’s better suited for the “Test Spy” pattern like the articles above mention.

Advertisements

Leave a comment

Filed under open standards, opinionizing, utility

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s