Run MSTests without Visual Studio 2008

The Microsoft unit testing framework comes with the MSTest.exe to run tests from command-line. This only works on machines that have Visual Studio installed. With some tweaks you can make it run on a computer without Visual Studio (see here). But that requires to add some keys to the registry and copying a bunch of assemblies which might not be an option for a pre-production or production environment.

So I decided to write a little command-line application that runs all tests in an assembly. You can download it from codeplex. It basically does the following:

  1. Load assembly with tests
  2. Load configuration file for assembly
  3. Find all classes marked with the TestClass attribute
  4. Find all methods marked with the TestMethod attribute and execute them

A failing assert statement will throw an exception which the test runner application handles. So counting the passed and failed tests is trivial such as measuring the execution time with a Stopwatch.

2 comments to Run MSTests without Visual Studio 2008

  • I’m curious as to why you chose MSTest to start with. Besides the fact that it comes baked into Visual Studio, I can’t think of any reason for using MSTest over NUnit. Its user interface is bad compared to NUnit, its start-up time is significantly higher than NUnit, and, yes, it takes dependency on Visual Studio.

  • Bernd

    Hi Ronnie,

    I have always been working with NUnit and loved it. But Microsofts Team Foundation Server has only full support for MSTest. Like if you want to have unit test statistics in the TFS report you must use MSTest. Another advantage could be that you can use your MSTests for load testing and it is very easy to create data-driven tests.

    Kr., Bernd.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>