Get Started
The instructions below will be given for Visual Studio with ReSharper. The instructions for JetBrains Rider look similar. For more information about running tests by using the standalone dotMemory Unit launcher, refer to Use dotMemory Unit Standalone Launcher.
note
* This command installs the latest stable dotMemory Unit build. If you want to install the latest EAP build, use the
Install-Package JetBrains.DotMemoryUnit -pre
command.
Open your test project in Visual Studio.
Open NuGet console using the menu Tools | NuGet Package Manager | Package Manager Console.
Install dotMemory Unit package by running the command*:
PM> Install-Package JetBrains.DotMemoryUnit
After this, ReSharper's menus for unit tests will get the additional item Run Unit Tests under dotMemory Unit.
Create a new test or modify the existing one by adding "memory" assertions.
We strongly recommend that you take a look at 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.
To run all tests with the dotMemory Unit support, use the menu ReSharper | Unit Tests | Run All Tests under dotMemory Unit.
If you want to run only a particular test, click the test mark in the gutter and select Run under dotMemory Unit .

Note that if you run a test using Run (without dotMemory Unit support), the test will fail. If you want the test runner to ignore dotMemory Unit calls, add 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.
note
This is a default behavior. You can change the auto-saving policy by using the DotMemoryUnit attribute. Thus, you can save a snapshot on any test failure or do not save it at all.
