I am trying to use NUnit Runners 2.6.4 to run all test assemblies in my test folder. My current command looks like this:
/nologo /noshadow /framework:net-4.0 /xml:.\test\TestResults.xml .\test\*.Test.dll
Unfortunately Nunit just throws a System.ArgumentException: Illegal characters in path.
Is there anyway I can achieve this?
Use nunit-console.exe to run tests from the command line. This will run the unit tests and save the results in the results. xml file, which you can work with easily.
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.
You can use following PowerShell command (for NUnit3, for NUnit2 change runner name):
PS> nunit3-console (ls -r *\bin\Debug\*.Tests.dll | % FullName | sort-object -Unique)
Command from previous answer runs each test assembly in separate nunit process synchronously. Presented here command runs all test assemblies in single nunit instance, which allows to leverage engine built-in parallel test run.
Remarks
Remember to tweak directory search pattern. Given example runs only assemblies ending with .Tests.dll
and inside \bin\Debug
directories.
Be aware of Unique
filtering - you may not want to have it.
It's not possible to use the wildcards for the input files, but you can specify multiple test libraries in the command line:
/nologo /noshadow /framework:net-4.0 /xml:.\test\TestResults.xml .\test\SomeLib1.Test.dll .\test\SomeLib2.Test.dll .\test\SomeLib3.Test.dll
From the official documentation:
An input file may be a managed assembly (.dll or .exe) containing tests or a project file recognized by NUnit. Out of the box, the following project types are recognized:
NUnit project files (.nunit)
Visual Studio solutions (.sln)
Visual Studio projects (.csproj, .vbproj, .csproj)
UPDATE
You could use a batch file to run the command for all files in the folder:
for /f %%f in ('dir .\test\ /b /s *.Test.dll') do nunit-console /nologo /noshadow /framework:net-4.0 /xml:.\test\TestResults.xml "%%f"
The dir
command selects names of the files from the .\test\
folder using the *.Test.dll
template. The names are passed to the command (nunit-console
) one by one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With