Testing/Error-OnTestFailure.ps1

function Error-OnTestFailure {
    Param(
        [Parameter(Mandatory=$true,Position=1)]
        [string]$BuildNumber
    )

    if (!(Test-Path "C:\Testing\$BuildNumber\Results.xml")) {
        return
    }

    [xml]$XUnitXml = Get-Content "C:\Testing\$BuildNumber\Results.xml"
    $FailedTests = $XUnitXml.SelectNodes('/assemblies/assembly/collection/test/failure').Count
    if ($FailedTests -gt 0) {
        throw "$FailedTests test(s) failed."
    }
}

Export-ModuleMember -Function Error-OnTestFailure