MSTestContrib 1.0.0 available for download/NuGet.

Late last night I uploaded the RTM release of MSTestContrib 1.0.0 to the MSTestContrib project portal up on CodePlex. This release of MSTestContrib includes the ability to write BDD-style unit tests simply by sub-classing MSTestContrib.Specifications.Specification and decorating the class and methods with a few attributes.

Getting Started

The easiest way to get going with MSTestContrib is to install it using the NuGet package manager. If you have ASP.NET MVC 3.0 RC2 or above installed you already have NuGet installed. On the NuGet console issue the command “install-package MSTestContrib” with the unit test project selected as the default project.

MSTestContribInstallPackage

If you don’t have access to NuGet you can still download a zip file that contains just the MSTestContrib DLL from the project portal releases page. The MSTestContrib.dll file needs to be referenced by the unit test project. Once this is setup you can create a new test class as per the normal process and then sub-class MSTestContrib.Specifications.Specification and add some attributes. The test method implementation just uses a series of methods to build up the BDD-style statement. The following code sample (gist 760628) shows a specification without any implementation detail provided.

Running this test using MSTest will produce an inconclusive result. The result summary view functions as you would normally expect.

MSTestContribTestResults

Drilling in a bit closer to the individual test result you can see that MSTestContrib has reproduced a textual representation of the BDD-style test, spelling out the specification description, scenario description and the various BDD statements. At the end of each statement there is a “NotImplemented” indicator which is the cause of the inconclusive test result.

MSTestContribInconclusiveResult

The following code sample (gist 760641) shows a completed test specification including not only the plain text description of the test case but also a function/expression that implements that description.

If the Add(…) method on the calculator threw an exception then the test result output would provide not only the text-based representation of the specification but also all of the exception detail. The following screenshot provides an example of the output.

MSTestContribFailedResult

It’s not pretty but there are limits to how much formatting you can put into the error message within the MSTest framework.

MSTestContrib Goals and Non-Goals

I wrote MSTestContrib primarily as a BDD-framework that I was happy using. There are dozens of BDD frameworks out-there including some really great ones. I was inspired by StoryQ but I wanted something that was simpler still. By taking dependencies on MSTest (the out of the box unit testing framework that comes with Visual Studio 2010) I hope to reduce barriers to entry for developers who have not done BDD-style development before.

Over time I am hoping that MSTestContrib will be extended with other framework elements which support teams that are investing in MSTest. If Microsoft produces tooling in MSTest which makes elements of MSTestContrib redundant then those features will be depreciated.

6 thoughts on “MSTestContrib 1.0.0 available for download/NuGet.

  1. Pingback: Tweets that mention MSTestContrib 1.0.0 available for download/NuGet. « notgartner -- Topsy.com

  2. Pingback: Links–01/03/2011 « Team System Rocks!

  3. Pingback: NHashcash 1.1.0 is in the public NuGet repository. « notgartner

  4. Pingback: January 4, 2011 – TFS Links and Quick Hits | Learn TFS

  5. Pingback: January 6, 2011 – TFS Links and Quick Hits | Learn TFS

  6. Pingback: MSTestContrib 1.0.0 available for download/NuGet. | Gifts of Life

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