Skip to content

Instantly share code, notes, and snippets.

@Kyle-Muir
Last active September 21, 2015 23:40
Show Gist options
  • Save Kyle-Muir/35911c0e8890579c079e to your computer and use it in GitHub Desktop.
Save Kyle-Muir/35911c0e8890579c079e to your computer and use it in GitHub Desktop.
Methods for copying C# projects into an Artefacts directory and then running NUnit Console runner across them
function Copy-FilesFromDirectories($exclude, $dest, $sourceDir, $config) {
$folders = Get-ChildItem -Path $sourceDir -Directory -Exclude $exclude | ? { $_.Name.EndsWith("Test") -or $_.Name.EndsWith("Tests") }
Foreach($folder in $folders) {
$binDirectory = "$($folder.FullName)\bin\$config"
if ((Test-Path $binDirectory)) {
Write-Host "Coyping folder $($folder.Name) to $dest" -ForegroundColor "Yellow"
$destinationProjectDirectory = "{0}\{1}" -f $dest,$folder.Name
New-Item $destinationProjectDirectory -ItemType Directory
Copy-Item -Path "$binDirectory\*" -Dest $destinationProjectDirectory
}
}
}
function Run-Nunit ($toolsDir, $testAssembly)
{
$nunit = "$toolsDir\NUnit\bin\nunit-console.exe"
exec { &$nunit $testAssembly }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment