Rhino Mocks, Unit Testing

Rhino Mocks Unit Tests (let the healing begin)

Over the past few days I have been focusing on “removing” the Record/Replay functionality from Rhino Mocks. I am a little surprised of how easy it was. The first step was to change all of the public methods in the MockRepository class to internal. The second step (and last step) was to add some methods to generate repositories. Granted, this doesn’t actually remove the Record/Replay functionality but it does “hide” it. Clearly taking baby steps.

Attempting to build everything and run the unit tests… not so much. Definitely got the “red” part down.

So I did the only thing that seemed reasonable, exclude every single class from the unit test project. I would have loved to have stopped right there and called it a day but (as with all good unit testers); no “green,” no “go.”

Now I am in the middle of changing every test, one-by-one. It is amazing how many of the tests utilize the Record/Replay style. It actually feels like every single test.

So far, the stats are as follows:

  • Original Passing Tests: 806, Original Skipped Tests: 2
  • Current Passing Tests: 461, Current Skipped Tests: 6

As I modify these tests (attempting to maintain the original intent), I have been noticing some of the constructs simply don’t make sense any more. Things like the BackToRecord and Replay methods as well as the Expect, LastCall, SetupResult and With utility classes. And don’t get me started on OrderedMethodRecorder and UnorderedMethodRecorder.

I am confident that these constructs will find their place in history soon enough. But first… the unit tests must be cured. Then the real slicing can begin.

Advertisements
Standard

2 thoughts on “Rhino Mocks Unit Tests (let the healing begin)

  1. Are you planning to enable using the “old” Rhino.Mocks alongside your “new” one in the same project?

    We’ve got a metric ton of unit tests written with Record/Replay (before we knew better) and re-writing them all is likely not something I could justify to management. If we we can’t use old & new Rhino.Mocks together then we won’t be able to use anything new that gets added by your good self. 😦

    Thanks for picking up the baton, BTW!

  2. Pingback: Dew Drop – June 27, 2013 (#1,574) | Alvin Ashcraft's Morning Dew

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