Using dotMemory Unit Standalone Launcher
If you run tests with a standalone unit test runner (rather than Visual Studio) 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 the 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.
For the detailed information on available tool parameters, run:
dotMemoryUnit.exe -help
Running Tests Using dotMemoryUnit.exe
In the simplest case, all you have to do is specify the path to your unit test runner and its arguments. For instance, in the following example we want to run NUnit tests from the MainTests.dll:
dotMemoryUnit.exe -targetExecutable="C:\NUnit 2.6.4\bin\nunit-console.exe"
--"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
...
Providing Arguments in an XML File
Sometimes, passing arguments to the tool in the command-line is not convenient or not possible. For example, you can exceed the OS's limit on arguments length if you have too long paths. In this case, you can pass arguments to dotMemoryUnit.exe in an XML file. Note that when using the XML file you can still provide any number of arguments in the command-line. The parameters provided in the command-line override the same ones from the file.
To create an XML file with sample configuration, use the -printXmlConfig
argument. For example:
dotMemoryUnit.exe -printXmlConfig > MyConfig.xml
dotMemoryUnit.exe Exit Code
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 -returnTargetExitCode
argument. For example:
dotMemoryUnit.exe -targetExecutable="C:\NUnit 2.6.4\bin\nunit-console.exe" -returnTargetExitCode
--"E:\MyProject\bin\Release\MainTests.dll"
Note that arguments to the target executable must always be passed in the end of the command.