Translate Skipped the test results into something Azure DevOps does NOT understand (#9124)

This commit is contained in:
Travis Plunk 2019-03-20 13:25:39 -07:00 committed by GitHub
parent cdbf6d60a3
commit b632b60fca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1218,9 +1218,21 @@ function Publish-TestResults
# In VSTS publish Test Results
if($env:TF_BUILD)
{
$resolvedPath = (Resolve-Path -Path $Path).ProviderPath
Write-Host "##vso[results.publish type=$Type;mergeResults=true;runTitle=$Title;publishRunAttachments=true;resultFiles=$resolvedPath;]"
$fileName = Split-Path -Leaf -Path $Path
$tempFilePath = Join-Path ([system.io.path]::GetTempPath()) -ChildPath $fileName
# NUnit allowed values are: Passed, Failed, Inconclusive or Ignored (the spec says Skipped but it doesn' work with Azure DevOps)
# https://github.com/nunit/docs/wiki/Test-Result-XML-Format
# Azure DevOps Reporting is so messed up for NUnit V2 and doesn't follow their own spec
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=yaml
# So, we will map skipped to the actual value in the NUnit spec and they will ignore all results for tests which were not executed
Get-Content $Path | ForEach-Object {
$_ -replace 'result="Ignored"', 'result="Skipped"'
} | Out-File -FilePath $tempFilePath -Encoding ascii -Force
Write-Host "##vso[results.publish type=$Type;mergeResults=true;runTitle=$Title;publishRunAttachments=true;resultFiles=$tempFilePath;]"
$resolvedPath = (Resolve-Path -Path $Path).ProviderPath
Write-Host "##vso[artifact.upload containerfolder=testResults;artifactname=testResults]$resolvedPath"
}
}