Skip to content

Instantly share code, notes, and snippets.

@ryupold
Last active December 1, 2015 10:35
Show Gist options
  • Save ryupold/646c76a37c3809f6beac to your computer and use it in GitHub Desktop.
Save ryupold/646c76a37c3809f6beac to your computer and use it in GitHub Desktop.
loop test runs with nunit-console 3.0
$successTimeout = 5
$failedTimeout = 60
$command = "nunit3-console.exe --noresult "+$args[0]
if($args[0])
{
write-host "testing",$args[0]
write-host "NOTE: nunit3-console.exe needs to be in PATH"
echo ""
echo ""
$loop = 1
$testrun = 1
while($loop = 1){
$time = get-date
$cmdResult = iex $command
$failResult = echo $cmdResult | Select-String "\.*Failed :\.*"
$exceptionResult = echo $cmdResult | Select-String "\.*Error :\.*"
if($failResult -or $exceptionResult){
echo ""
echo ""
echo ""
write-host $time,": test run",$testrun,"failed"
echo ""
iex $command
#Start-Sleep 15
echo ""
echo ""
$Host.UI.RawUI.FlushInputBuffer()
$timeout = $failedTimeout
Write-Host "press any key to rerun tests (or wait",$timeout,"seconds)"
do {
Start-Sleep 1
$timeout -= 1
} until ($Host.UI.RawUI.KeyAvailable -or $timeout -lt 1)
$Host.UI.RawUI.FlushInputBuffer()
echo ""
echo ""
echo ""
}else{
$result = echo $cmdResult | Select-String "Tests run:"
write-host $time,$result -foregroundcolor "green"
Start-Sleep $successTimeout
}
$testrun = $testrun + 1
}
}else{
write-host "pass the path to a test-project as parameter" -foregroundcolor "red"
}
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment