Check to be sure that the test result file has actual results before uploading (#9253)
VSTS produces a warning if the result set is 0, we will skip uploading this to avoid the warning and better support automation scenarios. ## PR Context We have automation which checks our test results and if the result set is 0 for that file, a warning is produced. This PR will avoid uploading that file into the test results (which is valid, as there are no run tests). We will still add the file to our artifact list for completeness.
This commit is contained in:
parent
8a0ecaf620
commit
2f0d127ef8
|
@ -1230,7 +1230,13 @@ function Publish-TestResults
|
|||
$_ -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;]"
|
||||
# If we attempt to upload a result file which has no test cases in it, then vsts will produce a warning
|
||||
# so check to be sure we actually have a result file that contains test cases to upload.
|
||||
# If the the "test-case" count is greater than 0, then we have results.
|
||||
# Regardless, we want to upload this as an artifact, so this logic doesn't pertain to that.
|
||||
if ( @(([xml](Get-Content $Path)).SelectNodes(".//test-case")).Count -gt 0 -or $Type -eq 'XUnit' ) {
|
||||
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"
|
||||
|
|
Loading…
Reference in a new issue