Running unit tests in Visual Studio Express

The brilliant TestDriven.net can’t run in Visual Studio Express (well, from what I’ve heard, it can, but Microsoft asked for it to be removed).

Therefore, to run unit tests in Visual Studio Express, you must set your debugger application to point to NUnit.exe (or the brilliant MBUnit). This isn’t straightforward in Express and means editing the .csproj file by hand and telling it to run the NUnit exe.

Today, I wanted to run and debug some unit tests I’d written in the XNA Game Studio Express (Visual Studio Express with some XNA bits bolted on). I couldn’t have the excellent right click/run unit test feature and I thought there’s got to be a better way than editing the .csproj file manually.

So I changed the unit test project to be a console application and added this to the Main method.

public static void Main( )
{
AppDomain.CurrentDomain.ExecuteAssembly(
@"C:Program FilesNUnit-Net-2.0 2.2.9binNUnit-console.exe",
null,
new string[ ] { Assembly.GetExecutingAssembly( ).Location } );
}

And it worked. Which was nice.

Update: #

Jamie recently left a message saying that the new Beta version DOES support Express editions! Read his post here and get downloading straight away!

🙏🙏🙏

Since you've made it this far, sharing this article on your favorite social media network would be highly appreciated 💖! For feedback, please 🦋 ping me on Bluesky! 🦋

Leave a comment

Comments are moderated, so there may be a short delays before you see it.

Published