dotTrace Web Help

There are three ways of profiling unit tests:

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

    Note

    This feature is available under Visual Studio 2005 or higher with JetBrains ReSharper 5.0 or higher.

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. The Profiler Configuration dialog box opens, where you should specify Profiling type and Measure or accept default values. For more information, see Choosing the Right Profiling Method and Choosing the Right Time Measurement Method.
  8. Optionally, click the arrow to display and configure additional settings, such as High accuracy, Enable inlining, Merge threads with equal names etc.
  9. After test execution is completed, a snapshot will be displayed.

    Note

    If dotTrace is set to run with administrator privileges (the Run this program as an administrator option is enabled in the application Compatibility properties) and Visual Studio is run under standard account, dotTrace will not receive the snapshot data. In such a case, either re-run Visual Studio as an administrator or set dotTrace to run under standard account.

Note

If you have several versions of dotTrace installed on your computer, the latest one is automatically selected.

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. The Profiler Configuration dialog box opens, where you should specify Profiling type and Measure or accept the default values. For more information, see Choosing the Right Profiling Method and Choosing the Right Time Measurement Method.
  4. Optionally, click the arrow to display and configure additional settings, such as High accuracy, Enable inlining, Merge threads with equal names etc.
  5. 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. Do one of the following:
    • On the menu bar, choose File | Profile. The Profile dialog box opens. Click Standalone Application, then click OK or just double-click Standalone Application.
    • Click Profile on the Home tab. Click Standalone Application in the drop-down list.
  3. The Profiler Configuration dialog box opens.
  4. By default, your application will be profiled on the local computer. If you want to start profiling on a remote computer, click Profile on remote computer to change host settings. For more information, see Profiling Remote Applications.
  5. 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.
  6. Specify the path to the .dll file with your unit tests and add arguments (if necessary) in the Arguments field.
  7. Optionally, click the arrow to display and configure additional options, such as Working Directory and Profile child processes.
  8. Specify Profiling type and Measure, or accept default values. For more information, see Choosing the Right Profiling Method and Choosing the Right Time Measurement Method.
  9. If you want dotTrace Performance to start taking measurements after you explicitly tell it to do so, clear the Start profiling immediately check box.
  10. Optionally, click the arrow to display and configure additional settings, such as High accuracy, Enable inlining, Merge threads with equal names etc.
  11. Optionally, you can select the Use profiler API check box.
  12. Click Run.
Test Runner Application Arguments
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 dll file with unit tests.
Example: "C:\Projects\ConsoleApplication1\ConsoleApplication1Test\bin\Debug\ConsoleApplication1Test.dll"
nunit-console.exe for nUnit Path to test runner executable.
Example: "C:\Program Files (x86)\NUnit 2.5.3\bin\net-2.0\nunit-console.exe"
Path to 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 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 test runner executable.
Example: "C:\Prog\xunit-1.5\xunit.console.exe"
Path to 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 Performance as an administrator.

To launch profiling of your unit tests with dotTrace Performance from Visual Studio, choose dotTrace | Profile Application on the Visual Studio menu bar, and follow the procedure for profiling unit tests from dotTrace Performance invoked as a standalone application.