Nunit test execution through commandline

Nunit-Console is used to run the NUnit test through a command-line tool. We need to install Nunit-Console , https://github.com/nunit/nunit-console/releases and add the path to environment variables. To verify the installation , 

nunit3-console.exe

 

The successful installation gives the option.

Now to execute the project scripts, navigate to bin/Test/net6.0 (based on framework it change) where the projectname.dll exists

To execute the Nunit test,

Specifying the Class - nunit3-console projectname.dll --where "class == namespace.classname"
Specifying the Method - nunit3-console projectname.dll --where "method == testMethod"
Specifying based on the categories - nunit3-console projectname.dll --where "cat == Smoke"


[Test]
[Category("Smoke")]
public void loginMethod()
{
      
}


When the test is executed through the command line the TestResult.xml will be generated by default and saved.

To display in the desired location nunit3-console projectname.dll --where "class == namespace.classname" --result=..\..\..\TestMatrix.xml.

To display the console output in the file --out=TestReport.xml 

nunit3-console projectname.dll --where "class == namespace.classname" --result=..\..\..\TestMatrix.xml --out=TestReport.xml
 
 

 

Related Tutorials