Updated templates for xUnit.net in ASP.NET MVC RTM

Sunday, 3 May 2009 by alexandrul

Environment:

  • Visual Studio 2008 Pro
  • xUnit.net v1.5 (build 1.5.0.1479)

xUnit.net has very few tests by default, so I have adapted the standard Visual Studio tests generated for ASP.NET MVC web applications. This resulted in two files: AccountControllerTests.cs and HomeControllerTests.cs (the last one is similar with HomeControllerFacts.cs)

The xUnit.net template for ASP.NET MVC unit testing can be found on the following location:

%VS2008%\Common7\IDE\ProjectTemplates\CSharp\Test\XunitMvcTestProjectTemplate.cs.zip

After unpacking the content of the template to a temp folder, we must place the new files in the Controllers folder, and update the content of MvcTemplate.csproj and MyTemplate.vstemplate:
[Read More…]

Setup xUnit.net for unit testing in ASP.NET MVC RTM

by alexandrul

Environment:

  • Visual Studio 2008 Pro
  • xUnit.net v1.5 (build 1.5.0.1479)

If you are using a zip file downloaded from the Source Code section of their site, extract it on a temp folder and move the binaries from the Samples\xunit folder to your destination of choice. If you are using the zipped binaries from their downloads page, simply extract them to your desired location.

The next step is running xunit.installer.exe and enabling support for ASP.NET MVC. The result should look like this:

xunit_installer_success.png

If the installer throws an exception like this one:

xunit_installer_error.png

then you should create manually the folder specified in the error message (usually the Test folders).
[Read More…]