Thursday, March 03, 2016

Find all NUnit test assemblies recursively and run them using PowerShell

In order to grab all unit tests assemblies recursively within folder and run them using NUnit I used following PowerShell script. Here I am filtering assemblies found in obj folder.

$nunit = "C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console.exe"
$assemblies = ""
$items = Get-ChildItem  -Path .\Test  -Filter *UnitTests.dll -Recurse | Where {$_.FullName -notlike "*\obj\*"} 

foreach ($item in $items)
$assemblies = $assemblies + " " + $item.FullName  

$nunitcmd = """C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console.exe"" $assemblies /nologo /xml=c:\dump.xml"
cmd /c $nunitcmd