How to execute NUnit test cases from command prompt

Use nunit-console.exe to run tests from the command line.

For example:

nunit-console.exe /xml:results.xml path/to/test/assembly.dll

This will run the unit tests and save the results in the results.xml file, which you can work with easily.

See the documentation for all of the various command line switches that are available.


I would like to add a few words about the latest version of NUnit. The name of the console application has changed to nunit3-console.exe in NUnit 3. Information about all possible options can be found in the official documentation. For example, run all tests in the assembly (the results are saved into the TestResult.xml file by default).

nunit3-console.exe path/to/test/assembly.dll

I've just find another nice solution:

Adding the following command to the "Build Events" / "Post-Build Events", will run the tests in Nunit-Gui automatically after the project has been built.

I hope this can be useful:

"C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-x86.exe" $(TargetPath) /run