Skip to content

Instantly share code, notes, and snippets.

@johannesprinz
Created July 20, 2017 21:55
Show Gist options
  • Save johannesprinz/4b65a0f103bbb08c48a4f0bd11975a89 to your computer and use it in GitHub Desktop.
Save johannesprinz/4b65a0f103bbb08c48a4f0bd11975a89 to your computer and use it in GitHub Desktop.
properties {
$dir = @{
base = (Get-Item -Path $psake.build_script_dir).FullName;
src = (Get-Item -Path (Join-Path -Path $psake.build_script_dir -ChildPath '..\')).FullName;
bin = Join-Path -Path $psake.build_script_dir -ChildPath "bin";
}
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "")]
$tool = @{
mstest = (Get-Item -Path "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe").FullName;
}
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "")]
$file = @{
csResultXml = Join-Path -Path $dir.bin -ChildPath "CSTestResult.xml";
}
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "")]
$test = @{
unit = "MyUnitTests.dll";
}
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "")]
$configuration = "Debug"
}
Task Clean {
Remove-Item -Path $dir.bin -Recurse -Force -ErrorAction SilentlyContinue
}
Task Test-MSTest -Depends Clean {
Push-Location -Path (Join-Path -Path $dir.src -ChildPath "MyUnitTests" |
Join-Path -ChildPath "bin" |
Join-Path -ChildPath $configuration)
exec{ & "$($tool.mstest)" "/testcontainer:$($test.unit)" "/resultsfile:$($file.csResultXml)" "/nologo" } |
ForEach-Object {
$status = if([string]::IsNullOrEmpty($_)) {
"NULL";
} else {
$_;
}
Write-Progress -Id 1 -Activity "Executing Unit Tests" -Status $status;
} #| Out-Null
Pop-Location
Format-MSTestResult -ResultPath $file.csResultXml;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment