Los Techies : Blogs about software and anything tech!

Assert.That(this, Is.Easy);


I came up with this a month or two ago, but finally decided to share it. While working on Mass Transit, I was joking with Dru Sellers about how nice it was to have really good test coverage when making design changes to some all-new development code. I've had very limited opportunity for a completely new projected started purely from unit tests, so I was just impressed at how easy it was to make code changes knowing that a passing set of tests meant all was well in the world.

You see, not all parking lots are paved with quality asphalt, generally flat, and void of any obstructions like islands and lights (see my other hobby). At work, our application is a lot of vintage C++ code, a ton of stored procedures packed to the hilt with domain logic, and nearly zero percent unit test coverage. Since adapting agile development, it is something that has been missing from our process. In our latest iteration, we've started using unit tests (with NUnit) to design our interfaces and classes. At the same time, we're integrating Mass Transit to support the loosely coupled layer of application services (which include object translation, communication with high-latency remote systems, and lazy auditing of transactions). Aside from a few basic web services to support remote client application support tools, this is the first C#/.NET development that is being done as part of the main application.

So back to our story, my first project with really good test coverage exposed me to a lot of new things. From a TDD perspective, I'd read about it, used it to build some basic tests for various classes, and thought I had a pretty decent understanding of it. In this new project, I also learned how to use Rhino.Mocks (which took the test run time from 40-50 seconds down to 1.83 seconds on average), a very powerful tool for making an interface behave as you would expect an implementation of that interface to behave. The use of mocks has really helped me focus on actually writing tests and building a single class at a time. Prior to using mocks I would jump around creating additional classes as I defined new interfaces just to be able to continue writing my unit tests on the original class. By using a mock, I'm able to simulate the behavior of the other class without losing focus.

As my appreciation for TDD grew, I jokingly dropped a slogan into a chat window (using Skype, of course, aren't you?):

Assert-That-This

I got a few chuckles, and thought it would make a great t-shirt to wear to tech events like code camps. So I threw together a quick online store so that I could order one for myself. I showed it to a few others (like Joe Ocampo, who suggested the slightly less offensive, yet subtly more suggestive variant) and decided to make it available to anyone that wanted one. So if you like it, grab one for yourself and maybe I'll see you wearing it at ALT.NET Seattle!

Kick It on DotNetKicks.com
Posted Jan 21 2008, 10:10 AM by Chris Patterson
Filed under: ,

Comments

bogardj wrote re: Assert.That(this, Is.Easy);
on 01-21-2008 10:34 AM

Or BDD-style:

this.***.ShouldBeEasy();

Assert.That(this, Is.Easy); | Online Services wrote Assert.That(this, Is.Easy); | Online Services
on 01-21-2008 11:22 AM

Pingback from  Assert.That(this, Is.Easy); | Online Services

Available Domain » Blog Archive » Assert.That(this, Is.Easy); wrote Available Domain » Blog Archive » Assert.That(this, Is.Easy);
on 01-21-2008 12:27 PM

Pingback from  Available Domain  » Blog Archive   » Assert.That(this, Is.Easy);

{codesqueeze} wrote Squeezed Links: February 2008
on 02-27-2008 10:02 AM

Feels like I haven’t done a squeezed links in awhile. Completely not related to software I have two new favorite sites that you should go check out - Daily Monster and Indexed. Be especially sure to check out Indexed - Indexing a Career: A Care

Daily Bits - February 28, 2008 | Alvin Ashcraft's Daily Geek Bits wrote Daily Bits - February 28, 2008 | Alvin Ashcraft's Daily Geek Bits
on 02-28-2008 8:03 AM

Pingback from  Daily Bits - February 28, 2008 | Alvin Ashcraft's Daily Geek Bits

Bill Campbell wrote re: Assert.That(this, Is.Easy);
on 02-28-2008 12:52 PM

so - what's your secret in learning RhinoMocks? Did you find a good tutorial or did you just plow through the docs yourself? I sure would love to learn how to us it!

regards!

Chris Patterson wrote re: Assert.That(this, Is.Easy);
on 02-28-2008 4:27 PM

@Bill:

I spent a lot of time looking through Ayende's site -- there are a lot of good examples there. I also read the PDF document that shows how to use all the features to setup expectations.

Aside from that, there was a LOT of trial and error! Sounds like a good topic for a series of blog posts to me.

Bill Campbell wrote re: Assert.That(this, Is.Easy);
on 03-01-2008 11:15 AM

Chris,

Yes - I have been reading through the docs as well and watched the Hibernating Rhino video. I get the high level, but am having a hard time understanding the details of Expect.Call and it's params and return as well as the LastCall.IgnoreArguements. I'll keep reading. This would make a great series of blog posts for sure! I'll bet there are lots of others that would benefit from that as well. Might you do this?

http://www.lostechies.com/blogs/chris_patterson/archive/2008/01/21/assert-that-this-is-easy.aspx wrote http://www.lostechies.com/blogs/chris_patterson/archive/2008/01/21/assert-that-this-is-easy.aspx
on 03-24-2008 2:56 AM
Copyright Los Techies 2008, 2009. All rights reserved.
Powered by Community Server (Commercial Edition), by Telligent Systems