Note that the following steps are given for the case when the ReSharper unit test runner is used. For the details on how to run tests using the standalone dotMemory Unit launcher, refer to Using DotMemory Unit Standalone Launcher.
1. Install dotMemory Unit into Test Project
- Open your test project in Visual Studio.
- Open NuGet console using the menu .
- Install dotMemory Unit package by running the command*:
PM> Install-Package JetBrains.DotMemoryUnit
2. Write a Memory Test
We strongly recommend that you acquaint with examples of the most commonly used tests in the Examples section. This will give you a brief understanding of how "memory" tests should be written.
3. Run the Test
To run all tests with the dotMemory Unit support, use the menu
If you want to run only a particular test, click on the test mark in the gutter and select Run under dotMemory Unit. Note that if you run a test using (without dotMemory Unit support), the test will fail. If you want the test runner simply to ignore dotMemory Unit calls, apply the
[DotMemoryUnit(FailIfRunWithoutSupport = false)]attribute on the desired scope: a method, a class, or an assembly.
If the test fails, dotMemory Unit automatically saves* the corresponding memory snapshot so that you can investigate it in the dotMemory profiler. The location of the snapshot is shown in the message to the failed test.