Are your unit tests still hard to read ? – Should Assertion Library

I created the Should library to fill a gap in the testing ecosystem in the .Net space.  Simply put, I took what I liked about using extension methods to make a more readable set of assertions, but made the library independent of any specific unit test framework. The last point is important, because this library can be used with all unit test frameworks. There were similar tools to this previously, but they all were tied to specific libraries so I could not have a consistent language when I move between test frameworks.

Cleaner syntax

First, consider the syntax and the readability of the assertions of a unit test. This is what a null check looks like using should.


versus the equivalent syntax using MSTest.


Install it now

Should is available on nuget.

install-package Should

Learn more about it

Start by watching this short video

There are a number of place to learn more about Should.

There is a second dialect of Should called Should.Fluent.  Learn about it here:

About Eric Hexter

I am the CTO for QuarterSpot. I (co)Founded MvcContrib, Should, Solution Factory, and Pstrami open source projects. I have co-authored MVC 2 in Action, MVC3 in Action, and MVC 4 in Action. I co-founded online events like mvcConf, aspConf, and Community for MVC. I am also a Microsoft MVP in ASP.Net.
This entry was posted in .Net, CodeProject, Open Source Software, OSS, Should, testing, Unittests. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • Dennis Doomen

    Why did you create another while a nice one already exists? See

    • erichexter

      I created this in 2010. Im just blogging more about it now.

    • I had some conversations with them early on.. My perfered syntax does not use the . notation.. I am a huge fan of a single method extensions versus the chained methods and properties.

      • Dennis Doomen

        Actually, that would have been me :-)

        • erichexter

          In that case, this was a rhetorical question :)

          • Dennis Doomen

            Yeah, sorry, I didn’t remember your name from that discussion. But since it is a hell of a job creating a library like that, I was wondering why you choose to build your own.

          • erichexter

            So this project is a fork of xunit assertions. So it realky was not a lot of work to create this library.

    • Rich

      It also looks very similar to Sharp Tests Ex:

  • Feldman Sean

    Nicely done Eric.
    While I agree with Dennis, I think it’s a good thing to remind people that result.Should_be_equal_to(expected) is better for readability than Assert.AreEqual(result, expected).

  • Daniel Marbach

    Fluentassertions is the best out there!

  • Jallen

    Here’s another vote for FluentAssertions!

  • Not trying to be a hater but I’ve always found Shoudly to be better at creating human readable code. also that it contains extensions for collections/dictionaries etc and not just simple single objects. 

    • erichexter

      It is absolutely no surprise that there are strong opinions around testing. :)

  • Anthony Mastrean
  • Jason Cavaliere

    Good Stuff Man.  I’ve been lately turned on by the simplicity that MSpec brings, but some people are not comfortable with it.  this is a great way to transition them slowly away from mstest / nunit while maintaining a universal assertion interface.

  • Amit Malhotra

    How it is different from Shouldly