Reputation: 3117
I'm attempting to use the Test -> Runs -> Query endpoint to return a list of test runs for a particular release, as detailed here
Unfortunately whatever I put in as a query parameter (with the exception of $top
which does appear to filter), I appear to get every test run returned against the project.
For example, I know there are 14 test runs against a particular release.
I can get my release id with the following query...
https://smartassessor.vsrm.visualstudio.com/Smart End Point Assessment/_apis/release/releases?searchText=Release-103
If I then try to use that id in the test run query like this...
https://smartassessor.visualstudio.com/Smart End Point Assessment/_apis/test/runs?releaseIds=1678&api-version=5.0-preview.2
I get 529 results, which looks like most of the test runs agains the project.
Are the filters working against this endpoint? If so, how should I tweak my request to utilize the releaseIds
parameter.
Thanks
Upvotes: 2
Views: 622
Reputation: 30432
I can reproduce this issue. Seems the APIs are not available for now.
There is an issue submitted here for tracking this. You can also track the updates on it.
As a workaround, you can use below PowerShell script to filter the test runs by Release ID: (Alternately you can export the result to a *.CSV file)
Param(
[string]$collectionurl = "https://{account}.visualstudio.com",
[string]$project = "ProjectName",
[string]$releaseid = "1",
[string]$user = "username",
[string]$token = "password"
)
#Set the path and name for the output csv file
$path = "D:\temp"
$filename = "ReleaseTestRun" + "-" + $releaseid
# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$baseUrl = "$collectionurl/$project/_apis/test/runs"
$response = Invoke-RestMethod -Uri $baseUrl -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
$testruns = $response.value
Write-Host $results
$Releaseruns = @()
foreach ($testrun in $testruns)
{
$testrunID = $testrun.id
$runbaseUrl = "$collectionurl/$project/_apis/test/runs/$testrunID"
$runresponse = Invoke-RestMethod -Uri $runbaseUrl -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} | Where {$_.release.id -eq $releaseid} #| Filter the test run by Release ID
$customObject = new-object PSObject -property @{
"id" = $runresponse.id
"name" = $runresponse.name
"url" = $runresponse.url
"isAutomated" = $runresponse.isAutomated
"state" = $runresponse.state
"totalTests" = $runresponse.totalTests
"incompleteTests" = $runresponse.incompleteTests
"notApplicableTests" = $runresponse.notApplicableTests
"passedTests" = $runresponse.passedTests
"unanalyzedTests" = $runresponse.unanalyzedTests
"revision" = $runresponse.revision
"webAccessUrl" = $runresponse.webAccessUrl
}
$Releaseruns += $customObject
}
$Releaseruns | Select `
id,
name,
url,
isAutomated,
state,
totalTests,
incompleteTests,
notApplicableTests,
passedTests,
unanalyzedTests,
revision,
webAccessUrl | where {$_.id -ne $Null} #|export-csv -Path $path\$filename.csv -NoTypeInformation # Filter non-empty values and export to csv file.
Upvotes: 3