Tim Scott's Blog

October 8, 2010

Getting Started With Should Assertion Library

Filed under: Test Driven Development, Unit Testing — Tim Scott @ 7:04 pm

What Is It?

Should Assertion Library (“Should” for short) is a library of test assertion methods for .NET.  It is totally independent of, and completely compatible with any testing framework.  It was created by Eric Hexter, and I subsequently added a fluent interface which I ported from ShouldIt.  ShouldIt is now deprecated.

Should comes in two flavors:

  • normal (Should.dll)
  • fluent (Should.Fluent.dll).

Get It

You can get the latest binaries from NuPack or the project site.

By the way, if you haven’t tried NuPack yet, go get it right now!  You’ve got it? Okay, open the Package Management Console and enter:

> Install-Package Should


> Install-Package ShouldFluent

This will install Should as a package in the current solution.  You probably want to use either the fluent API or the normal API in any given test project – but not both.  Choosing one or the other will promote a consistent practice within your team.  Obviously, I prefer the fluent API.

Use It

There’s not much to say about usage.  It’s really pretty intuitive and discoverable.  Just start typing “.Should” after your actual object, and you will see what’s available.  To give you a taste, here’s a simple example:


Or fluently:


There are several examples of both the normal and the fluent syntax here.


A Note To ShouldIt Users: If you have been using ShouldIt, just remove the ShouldIt DLLs, add Should.Fluent.dll, and change the namespaces.  Everything should just work. Of course depending on which test framework you were using with ShouldIt, the underlying assertion behavior could change slightly. It should be pretty easy to spot the differences and make any small corrections as needed.


  1. […] tuned for my next blog post: Getting Started With Should Assertion Library. Leave a […]

    Pingback by Goodbye ShouldIt, Hello Should Assertion Library « Tim Scott's Blog — October 9, 2010 @ 7:23 pm

  2. Thought you might want to know, I’m shipping the Should framework with NBehave alpha… http://sharpfellows.com/post/NBehave-alpha-now-shipping-with-Should-assertion-framework.aspx

    Thanks for the great framework 🙂

    Comment by Naeem Khedarun — October 28, 2010 @ 3:52 pm

RSS feed for comments on this post. TrackBack URI

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: