User Manual > How to...

Perform Unit Testing together with the Profiler

It may sometimes be useful to perform unit testing (e.g. using NUnit) together with the profiler, especially when the .NET Memory Profiler API is used.

Normally it should not be a problem to run a unit test program under the profiler; you just need to select the program to run (e.g., NUnit-gui.exe, if running NUnit) and supply any necessary program arguments. However, unit testing frameworks usually work with dynamic application domains, and dynamic application domains do not work well with root identification under .NET Framework 1.x. Additionally, when using NUnit, heap utilization tracking cannot be enabled. Therefore, in order to profile a process running NUnit or some other unit testing framework under .NET Framework 1.x, it is recommended that you make sure that Enable root identification and Enable heap utilization tracking are not checked in the Session Settings form.

You can also start profiling from the command prompt. The following command line can, for instance, be used to start NUnit under the profiler:

NetMemProfiler.exe /ri- nunit-gui.exe [optional arguments to NUnit]

Normally, .NET Memory Profiler keeps the debug symbols file (.PDB) open when reading symbol information for an assembly. However, this will prevent the unit tested assembly from being recompiled while testing. To prevent this, the /shadowsymbols command line argument can be used.

For more information about command line arguments, see Command Line Arguments.

NOTE! If you use the Microsoft test framework (“MSTest“), you must make sure that the tests are run in the same process as the test framework. This can be accomplished by providing the argument /noisolation to test the MSTest application, e.g.,

NetMemProfiler.exe mstest.exe /noisolation [additional arguments to MSTest]