Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down