title: Running NUnit 3 from Powershell
body: <p>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:</p>
  
  <pre><code>RunTests.ps1 -NunitArgs "--where cat==QuickTests" -OutputPath "workdir"
  </code></pre>
  
  <p>The arguments are handled here:</p>
  
  <pre><code>param(
      [string]$OutputPath = "testResults",
      [string]$NunitArgs = "nunitOptions"
  )
  </code></pre>
  
  <p>NUnit is called (with a line to echo the command):</p>
  
  <pre><code>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"
  &amp; $(GetNUnitConsolePath) Test.dll $NunitArgs --work==$OutputPath
  </code></pre>
  
  <p>with the result:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The following line of code works as expected from the PS script:</p>
  
  <pre><code>&amp; $(GetNUnitConsolePath) Test.dll --where cat==QuickTests --work=workdir
  </code></pre>
  
  <p>The tests run, and the category filter &amp; work directory are set as expected:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I've also tried:</p>
  
  <pre><code>$arg1 = 'Test.dll'
  $arg2 = '--where cat==QuickTests'
  $arg3 = '--work=workdir'
  Write-Host "Executing: $(GetNUnitConsolePath) $arg1 $arg2 $arg3"
  &amp; $(GetNUnitConsolePath) $arg1 $arg2 $arg3
  </code></pre>
  
  <p>This results in the same output from NUnit:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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!</p>