Skip to content
ianoxley edited this page Oct 31, 2012 · 12 revisions

The MSTest task is designed to run tests written with the test framework integrated into Microsoft Visual Studio. This test framework is commonly referred to as MSTest.

How to use the MSTest Task

Because the MsTest executable location varies between versions of Visual Studio and platform (x86 / x64) it is necessary to specify the location of mstest.exe. This is done by setting the 'command' instance variable of the configuration object. In addition to command, the assemblies variable must also be set to specify the DLL(s) which include MSTest tests.

For example:

desc "MSTest Test Runner Example"
mstest :mstest do |mstest|
	mstest.command = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe"
	mstest.assemblies "output/YourProject.Tests.dll"
end

Note that MStest is installed to the following locations by default:

  • VS2008 / x86: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe
  • VS2008 / x64: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe
  • VS2010 / x86: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe
  • VS2010 / x64: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe
  • VS2012 / x86: C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe
  • VS2012 / x64: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe

Command-Line Options

This task supports additional command line options, including a .parameters collection for passing in options that are not directly supported. For more information, see the commandline task options documentation. MSDN has good documentation of all the command-line options for MSTest.

Clone this wiki locally