From 8f9666fe2da9c108e23df1b4dbe2eaaae16461c0 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Wed, 20 Mar 2019 13:25:39 -0700 Subject: [PATCH] Translate Skipped the test results into something Azure DevOps does NOT understand (#9124) --- build.psm1 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/build.psm1 b/build.psm1 index 658252cf61..c61750c9ec 100644 --- a/build.psm1 +++ b/build.psm1 @@ -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" } }