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 ru
To run the tests (Nunit3-console) remotely via Bamboo, I added this Bamboo Powershell script:
Invoke-Command -Credential $credentials -ComputerName $Server -ScriptBlock{
$pathToDdrive = "D:"
$pathtoDLL = Join-Path $pathToDdrive -ChildPath "RestOfThePathToDLL"
cd D:\...\NUnit.ConsoleRunner.3.10.0\tools
.\nunit3-console.exe $pathToDLL --where "cat=='API'"
}
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.
Visual Studio: 2017, 2019(Preview) On Mac use below command:
nunit-console <path/to/project>/<project-name>/bin/Debug/<project-solution-name>.dll
For example:
nunit-console /Users/pratik/Projects/selenium-mac13/selenium-test/bin/Debug/selenium-test.dll
nunit3-console.exe "path of the testfile (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
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