What a Difference a Clear Error Message Makes

Let me be the first to say (and everyone should echo in harmony) that this issue was 100% my fault. Today I spent at least an hour of my life trying to track down an issue caused, simply, by the fact that I was trying to mock a sealed class without realizing it…

The point of this post is not to illustrate what went wrong. The point of this post is to show the error messages displayed by two popular mocking frameworks and highlight the benefit of clear messages. Recently I’ve been using Telerik’s JustMock framework but in the past MOQ has been my framework of choice. I’ve always found MOQ’s messages useful – it seems like the developers put a lot of thought into what the user sees – and after struggling to debug the issue for a while I figured I’d switch frameworks (for this individual test) to see if it would provide any more insight.

Take a look at the difference between error messages. Which one would you prefer?

JustMock

System.InvalidProgramException : Common Language Runtime detected an invalid program

MOQ

System.ArgumentException : Type to mock must be an interface or an abstract or non-sealed class.

Note: I’m not trying to bash JustMock in any way. To date I have been pretty happy with said framework and this has been somewhat of an isolated issue…

Comments

Popular posts from this blog

Excel - Adding an existing Pivot table to the data model

Getting Started with Mirth (Part 1)

Mirth