Tuesday 17 November 2009

MbUnit Equality Assertions

The more I investigate MbUnit and the Gallio Automation Platform the more impressed I become.  The latest features I've been playing with are the new equality assertions in MbUnit 3.1.

How often would you like to do

Assert.AreEqual(a, b)

where a, b are object instances?

Suppose you haven't overridden Object.Equals and Object.GetHashCode. You shouldn't need to do these just because you want to write tests.

Gallio team member, Yann Trévin, has written an excellent post describing the new equality assertions in MbUnit 3.1 so there's nothing more for me to say here but this.

I ran up a modified and simplified version of his example in the Gallio UI and one cool feature I noticed is the differences highlighting you get when two object instances fail their equality test. Below is an object equality comparison performed using the StructuralEqualityComparer that Yann describes in his post.

image

As you can see, the differences in the values of each field are highlighted.