Child pages
  • Profiling Unit tests with dotTrace 4.0
Skip to end of metadata
Go to start of metadata

There are two major opportunities for profiling:

  • Using Resharper 5.0 + dotTrace (NUnit and MSTest are out of the box, xUnit with third-party plugin xUnitContrib)
  • Using standalone dotTrace (usable for any UnitTest frameworks: nUnit, MSTest, xUnit, etc.)

Using Resharper 5.0 + dotTrace

This howto works for both MSTest and nUnit.

1. Create or open a solution with some functionality and unit tests.

2. Use one of the two options shown on the screen to 

3. Tune up Profiler configuration or just press OK.


 4.After unit tests execution the snapshot screen will open automatically:

5. You may use Ctrl+F to search for your specific code

Using standalone dotTrace

1. Run standalone dotTrace.

2. Profile -> Local Computer -> Connect

3. Select "Profiler kind" = "Standalone application".

4. Application should be path to tests runner:

  • nunit.exe or nunit-console.exe for nUnit (it may require installation of nUnit):
    • nunit.exe
      • possible path is then: "C:\Program Files (x86)\NUnit 2.5.3\bin\net-2.0\nunit.exe"
      • Arguments should be path to the dll with unit tests. It may look like: "C:\Projects\ConsoleApplication1\ConsoleApplication1Test\bin\Debug\ConsoleApplication1Test.dll"
    • nunit-console.exe
      • possible path is then: "C:\Program Files (x86)\NUnit 2.5.3\bin\net-2.0nunit-console.exe"
      • Arguments:
        •  Path to the dll with unit tests;
        • /xml <filename> - file to store testrun results
      • So the complete list of arguments should look like: "C:\Test progs\ConsoleApplication1nUnit\ConsoleApplication1nUnitTest.dll" /xml:C:\Temp\1.xml
  • MSTest.exe for MSTest 
    • Possible path: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe"
    • Arguments:
      • /noisolation This argument tells MSTest to run tests within the MSTest.exe process.
      • /testcontainer:. This argument tells MSTest the path to the assembly that contains all of the tests.
    • So the complete list of arguments should look like: /noisolation /testcontainer:"C:\Projects\ConsoleApplication1\ConsoleApplication1Test\bin\Debug\ConsoleApplication1Test.dll"
    • Push "More" button in the profiler configuration -> Set the Working directory to the one that you have complete permissions. It could be "C:\Temp"


Icon

If you don't find the test code in the snapshot then make sure the tests are actually running. In some cases MSTest lacks some permissions and it stops before running tests. Try to run dotTrace as administrator.

  • xUnit-console.exe for xUnit
    • Possible path: "C:\Prog\xunit-1.5\xunit.console.exe"
    • Arguments:
      •  Path to the dll with unit tests;
      •  /xml <filename> - file to store testrun results
    • So the complete list of arguments should look like: "C:\Projects\ConsoleApplication1\ConsoleApplication1xUnit\bin\Debug\ConsoleApplication1xUnit.dll" /xml 1.xml
    • Push "More" button in the profiler configuration -> Set the Working directory to the one that you have complete permissions. It could be "C:\Temp"
  • No labels