Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute NUnit test cases from command prompt

How can I execute a test case from Command Console using NUnit? I had set of Selenium Tests written in C# based on NUnit framework. I need to execute the test cases simply by running from command console.

In JUnit we can run test case from cmd as

java junit.swingui.TestRunner test.Run 

How can we do above in NUnit?

like image 588
Harshavardhan Konakanchi Avatar asked Jun 18 '12 15:06

Harshavardhan Konakanchi


People also ask

How do I run NUnit test cases?

Create Test Runner Class It imports the JUnitCore class and uses the runClasses() method that takes the test class name as its parameter. Compile the Test case and Test Runner classes using javac. Now run the Test Runner, which will run the test case defined in the provided Test Case class. Verify the output.

How do I run nunit3 console exe?

Open a powershell window and run nunit3-console.exe with "--test" option set to reference the specific test you want to run (including namespace and class). and finally, provide the location of the assembly where the test can be found.

What is NUnit console runner?

The nunit-console.exe program is a text-based runner and can be used when you want to run all your tests and don't need a red/yellow/green indication of success or failure. It is useful for automation of tests and integration into other systems.


2 Answers

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.

like image 64
vcsjones Avatar answered Oct 02 '22 17:10

vcsjones


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 
like image 37
Sergii Zhevzhyk Avatar answered Oct 02 '22 17:10

Sergii Zhevzhyk