Profiling tests in MSTest

MSTest is a software unit testing framework developed by Microsoft, which lets you create, manage, and run unit tests from within the Visual Studio IDE, as well as from the command line.

You can profile tests running in MSTest. Profiling your tests ensures that you're quickly alerted to any bottlenecks in your tests.

This page assumes that you're familiar with MSTest, and have already built an assembly full of tests that you want to profile.

Before you start profiling, you'll need a debug build of your test assembly.

Setting up the performance profiler

When profiling tests, you're actually profiling MSTest.exe, with some additional setup options and arguments.

To profile tests:

  1. From the list of application types, select .NET executable.
  2. In Path to .NET executable type or browse to the location of MSTest.exe
    • For .NET 2.0 applications, this is often: %ProgramFiles(x86)%\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe
    • For .NET 4.0 applications, this is often: %ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe
  3. To add the command line arguments, click Show startup options.
  4. In Command line arguments set a /testcontainer argument to tell MSTest the path to the assembly that contains all of the tests.
    For example:
    /testcontainer:"C:\Documents and Settings\<USER NAME>\My Documents\Visual Studio 2012\Projects\LoginForm\MyTests\bin\Debug\MyTests.dll"
  5. Select the required Profiling modeChart performance counters,  Additional profiler options, and the browser to launch the application.
    For more information, see Working with application settings and Setting up chart performance counters.

  6. Click 

MSTest starts and executes all of the tests contained within the assembly.

During a profiling session you can interact with the profiler while your tests are still being profiled, and get results by selecting areas of the timeline; see The timeline.

When you've finished interacting with your application, click the  button in ANTS Performance Profiler to stop profiling.


Didn't find what you were looking for?