Use dotMemory Unit Standalone Launcher
If you run tests with a standalone unit test runner (rather than Visual Studio or JetBrains Rider) or want to make memory tests a part of your continuous integration builds, then you need a standalone dotMemory Unit launcher – the dotMemoryUnit.exe command-line tool.
dotMemoryUnit.exe works as a mediator – it runs a particular standalone unit test runner and provides support for dotMemory Unit calls in the running tests.
dotMemory Unit standalone launcher is distributed as a zip archive available for download on the dotMemory page. The dotMemory Unit NuGet package also contains the standalone launcher.
warning
If your domain policy is to treat files from the Internet as unsafe, do not forget to unblock the zip archive using the Unblock button in the file properties.
For the detailed information on available tool parameters, run:
dotMemoryUnit.exe --help
In the simplest case, all you have to do is specify the path to your unit test runner and its arguments. For example, this is how you can run tests from a file (say, MainTests.dll) with NUnit and dotnet
:
dotMemoryUnit.exe "C:\NUnit 2.6.4\bin\nunit-console.exe" -- "E:\MyProject\bin\Release\MainTests.dll"
dotMemoryUnit.exe "c:\Program Files\dotnet\dotnet.exe" -- test "E:\MyProject\bin\Release\MainTests.dll"
Tool's output contains data on successful and failed tests. For example:
...
Tests run: 3, Errors: 1, Failures: 0, Inconclusive: 0, Time: 28.3051788194675 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
Errors and Failures:
1) Test Error : MainTests.IntegrationTests.Method2
AssertTrafficException : Allocated memory amount
Expected: 50,000,000
But was: 195,344,723
...
By default, if tool finishes its work successfully, its exit code is 0. This is not very convenient when you run the tool on the CI server as you need to know whether there are any failed tests in the build. In such a case, the best option is to make dotMemoryUnit.exe return the exit code of your unit test runner. To do this, you should use the --propagate-exit-code
argument. For example:
dotMemoryUnit.exe "C:\NUnit 2.6.4\bin\nunit-console.exe" --propagate-exit-code -- "E:\MyProject\bin\Release\MainTests.dll"
Note that arguments to the target executable must always be passed in the end of the command.