Note that currently, dotMemory Unit only works on Windows. In order to be able to run unit tests with dotMemory Unit, we’ll have to install it. Adding dotMemory Unit to our test project And best of all: dotMemory Unit itself is completely free.īut enough with the marketing: let’s get to work. This is exactly where dotMemory Unit comes in: it is a unit testing framework which allows us to write tests that check our code for memory issues.ĭotMemory Unit (dMU) integrates with other test frameworks such as NUnit, MSTest and xUnit, and captures memory snapshots that can be analyzed using dotMemory – our memory profiler.
There are good reasons to not only run unit tests and integration tests, but also to monitor their behavior in terms of memory usage. Let’s write a test that verifies a certain object was properly removed from memory! Testing for memory leaks using dotMemory Unit
Unit testing bookz how to#
Today, let’s shift gears and look at how to write a similar type of test using the (free!) dotMemory Unit framework. In our previous post, we looked at how I caused a memory leak when working on a feature in Rider, and how I could not merge that feature into the product because the test that checks for a particular memory leak was failing.
Adding dotMemory Unit to our test project.Testing for memory leaks using dotMemory Unit.