Things have been quiet lately for my BDD framework, SpecsFor, but I have finally published version 2.0 to both Github and NuGet.  Read on to find out what’s changed.


PM> Install-Package SpecsFor

New Testing Styles

Prior to version 2.0, SpecsFor required you to write BDD-style specs.  While that’s still the primary use case, the new version relaxes this requirement by making both the Given and When methods virtual instead of abstract.  Now you can write “old-school” tests alongside BDD-style specs, as shown in these two examples:

One Package To Rule Them All

SpecsFor now comes with additional libraries, namely Derek Greer’s ExpectedObjects and Eric Hexter’s Should.  These two testing libraries are must-haves in my opinion, so it only makes sense that they should be included with SpecsFor.  If you add SpecsFor via NuGet, you’ll now have everything you need to easily create tests: NUnit, Moq, StructureMap.AutoMocker, ExpectedObjects, and Should. 

New Test Helpers

Beginning with version 2.0, my focus with SpecsFor is to create a package that includes (or, via NuGet, pulls in) everything you need for a painless TDD/BDD experience in .NET.  I’m also adding new test helpers and extensions to address common points of testing friction.  In this release, I’ve added two helpers.  The first addresses a common need, comparing two instances to see if their members are equivalent:

(Yes, this is the exact scenario the ExpectedObjects library addresses, but the extension method in SpecsFor packages it up a little more cleanly.)

Another common point of friction is Moq’s It.Is method.  Typically, verifying non-trivial types requires chaining Boolean expressions like this:

With SpecsFor, you can leverage the new Looks.Like method (which once again builds on ExpectedObjects) to achieve the same thing in a more readable, less-tedious way:

What’s Next?

The next thing that I’m cooking up under the SpecsFor umbrella will actually be a completely new project (albeit one that plays very nicely with the core SpecsFor library).  I’ll have more to say about that soon, but for now, I’ll just say that creating UI tests for ASP.NET MVC applications is about to become a lot less painful. Smile 

As for the core SpecsFor library, I’m open to suggestions on where to turn my attention next.  Test object creation?  Support for older versions of .NET?  Leave me a comment and let me know.  I’m also looking for help with creating a proper project website.  If anyone with some design/graphic talent would be willing to help out, please contact me.  As you can tell, I have about this much || design sense…