I have a PS script which I've been successfully using to run and process results from NUnit 2.6.3. I've recently upgraded to NUnit 3.2.1 and am having problems with passing arguments to the NUnit executable. The script is called from Octopus deploy like this:
RunTests.ps1 -NunitArgs "--where cat==QuickTests" -OutputPath "workdir"
The arguments are handled here:
param(
[string]$OutputPath = "testResults",
[string]$NunitArgs = "nunitOptions"
)
NUnit is called (with a line to echo the command):
function GetNUnitConsolePath
{
return join-path -path ${env:ProgramFiles(x86)} -childpath "NUnit-3.2.1\bin\nunit3-console.exe"
}
...
Write-Host "Executing: $(GetNUnitConsolePath) Test.dll $NunitArgs --work==$OutputPath"
& $(GetNUnitConsolePath) Test.dll $NunitArgs --work==$OutputPath
with the result:
Executing: C:\Program Files (x86)\NUnit-3.2.1\bin\nunit3-console.exe Test.dll --where cat==QuickTest
s --work=workdir
NUnit Console Runner 3.2.1
Copyright (C) 2016 Charlie Poole
Invalid argument: --where cat==QuickTests
The following line of code works as expected from the PS script:
& $(GetNUnitConsolePath) Test.dll --where cat==QuickTests --work=workdir
The tests run, and the category filter & work directory are set as expected:
NUnit Console Runner 3.2.1
Copyright (C) 2016 Charlie Poole
Runtime Environment
OS Version: Microsoft Windows NT 6.3.9600.0
CLR Version: 4.0.30319.34209
Test Files
Test.dll
Test Filters
Where: cat==QuickTests
Run Settings
WorkDirectory: workdir
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETFramework,Version=v4.5
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 8
Test Run Summary
Overall result: Passed
I've also tried:
$arg1 = 'Test.dll'
$arg2 = '--where cat==QuickTests'
$arg3 = '--work=workdir'
Write-Host "Executing: $(GetNUnitConsolePath) $arg1 $arg2 $arg3"
& $(GetNUnitConsolePath) $arg1 $arg2 $arg3
This results in the same output from NUnit:
Executing: C:\Program Files (x86)\NUnit-3.2.1\bin\nunit3-console.exe Test.dll --where cat==QuickTest
s --work=workdir
NUnit Console Runner 3.2.1
Copyright (C) 2016 Charlie Poole
Invalid argument: --where cat==QuickTests
I'm a PS noob, so hopefully it's something obvious I've overlooked in the script. I've also tried various iterations of Invoke-Command with -ArgumentList, but didn't get anywhere with that. All constructive suggestions are appreciated - thanks!