Start writing MSpec specifications (tests) for ASP.NET MVC 2


This article is a follow up to my previous post and it will show you how to get started with writing MSpec specifications (tests) for ASP.NET MVC2.

  • Create the ASP.NET MVC 2 application. I’ve named the application MSpecMvcApplication and I made sure that it’s using the same .NET Framework version as my “Machine.Specifications.dll” was built against.
Create MVC 2 project

Create MVC 2 project menu

  • Upon clicking OK, you’ll be asked if you want to create a unit test project, to which you should answer “Yes”. Note that there will be some irrelevant dlls referenced but this is for a quick demo on how to get up and running with writing MSpec tests.
  • You should end up with two projects
  • Add the “Machine.Specifications.dll” to the references.
  • Open up “HomeControllerTest.cs” and replace the code with:
  • Build the solution and run the test as follows:

  • If all goes well you should see:

  • This is not a “real” test, because there is no context or test condition. So a proper test would be something like:

In my next post I’ll try and explain what this code is doing but if you can run it, you’ll see

which is the result of a “real” test.

Advertisements
Tagged with: , ,
Posted in .NET, BDD, MSpec
2 comments on “Start writing MSpec specifications (tests) for ASP.NET MVC 2
  1. […] to Vote[FriendFeed] Start writing MSpec specifications (tests) for ASP.NET MVC 2 … (12/11/2010)Saturday, December 11, 2010 from […]

  2. […] URL: Start writing MSpec specifications (tests) for ASP.NET MVC 2 … Tags: article, asp, get-started, mvc, net, will-show, with-writing, you-how Comments RSS […]

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

%d bloggers like this: