dotTrace Help

Profiling Unit Tests

There are three ways of profiling unit tests:

  • Using standalone dotTrace.
  • Using Visual Studio and dotTrace.
  • Using Visual Studio, ReSharper and dotTrace.

The easiest and most convenient way is to profile the performance of unit tests from Visual Studio via ReSharper and dotTrace. When dotTrace is integrated with ReSharper, several new options appear in the ReSharper main menu as well as in ReSharper context menus.

To profile unit tests from the Visual Studio editor using ReSharper and dotTrace

  1. Open a solution in Visual Studio.
  2. Open a file with unit tests.
  3. Choose a test class or a test method.
  4. Click the corresponding side bar mark in the left gutter.
  5. In the context menu, choose Profile with dotTrace:
    Profiling_Tests_with_Unit_Test_Runner
  6. The Unit Test Sessions window opens.
  7. Specify profiling options in the Profiler Configuration window.
  8. After test execution is completed, a snapshot will be displayed.

You can also launch unit test profiling from ReSharper. Choose ReSharper | Unit Tests | Profile Unit Tests or ReSharper | Unit Tests | Profile All Tests from Solution on the menu bar.

To profile unit tests from ReSharper's Unit Test Sessions window

  1. Select a node in the tree view of the Unit Test Sessions window.
  2. Click Profile Selected Tests ico_unittest in the toolbar.
  3. Specify profiling options in the Profiler Configuration window.
  4. After test execution is completed, a snapshot will be displayed.

To profile unit tests using standalone dotTrace

  1. Run dotTrace as a standalone application.
  2. Choose the New Session | Local tab.
  3. In the central panel in Profile Application, select Standalone.
  4. Depending on which unit testing framework is installed, specify the path to its executable file in the Application field. Your can work with the following frameworks/executables:
    • nunit.exe for nUnit.
    • nunit-console.exe for nUnit.
    • MSTest.exe for MSTest.
    • xUnit-console.exe for xUnit.
  5. Specify the path to the .dll file with your unit tests and add arguments (if necessary) in the Arguments field.
  6. Optionally, check the Advanced option to configure additional options, such as Working Directory and Profile child processes.
  7. Specify profiling options in the Profiler Configuration window.
  8. Click Run.
Test RunnerApplicationArguments
nunit.exe for nUnit Path to test runner executable.
Example: "C:\Program Files (x86)\NUnit 2.5.3\bin\net-2.0\nunit.exe"
Path to the dll file with unit tests.
Example: "C:\Projects\ConsoleApplication1\ConsoleApplication1Test\bin\Debug\ConsoleApplication1Test.dll"
nunit-console.exe for nUnit Path to the test runner executable.
Example: "C:\Program Files (x86)\NUnit 2.5.3\bin\net-2.0\nunit-console.exe"
Path to the dll file with unit tests and name of xml file where test results are stored.
Example: "C:\Test progs\ConsoleApplication1nUnit\ConsoleApplication1nUnitTest.dll" /xml:C:\Temp\1.xml
MSTest.exe for MSTest Path to the test runner executable.
Example: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe"
Arguments:
  • /noisolation - run tests within the MSTest.exe process.
  • /testcontainer - load a file that contains tests that you want to run.
Example: /noisolation /testcontainer:"C:\Projects\ConsoleApplication1\ConsoleApplication1Test\bin\Debug\ConsoleApplication1Test.dll"
xUnit-console.exe for xUnit Path to the test runner executable.
Example: "C:\Prog\xunit-1.5\xunit.console.exe"
Path to the dll file with unit tests and name of xml file where test results are stored.
Example: "C:\Projects\ConsoleApplication1\ConsoleApplication1xUnit\bin\Debug\ConsoleApplication1xUnit.dll" /xml 1.xml

The resulting snapshot contains lots of information that pertains not only to the unit tests you're profiling but to test framework itself, making it a difficult task to extract information about unit tests. If you don't find unit test code in the snapshot at all, make sure the tests are actually running. In some cases MSTest stops before running tests due to inadequate permissions. If this is the case, try running dotTrace as an administrator.

See Also

External Links:

Last modified: 26 June 2015