Azure devops VSTS-测试->;运行->;查询终结点未基于参数进行筛选
我正试图使用Test->Runs->Query端点返回特定版本的测试运行列表,详细信息如下 不幸的是,无论我输入什么作为查询参数(除了Azure devops VSTS-测试->;运行->;查询终结点未基于参数进行筛选,azure-devops,azure-devops-rest-api,Azure Devops,Azure Devops Rest Api,我正试图使用Test->Runs->Query端点返回特定版本的测试运行列表,详细信息如下 不幸的是,无论我输入什么作为查询参数(除了$top,它看起来确实是过滤器),我似乎都会得到针对项目返回的每个测试运行 例如,我知道有14个针对特定版本的测试运行 我可以通过以下查询获取我的发布id https://smartassessor.vsrm.visualstudio.com/Smart 终点评估/_API/release/releases?searchText=release-103 如果我尝
$top
,它看起来确实是过滤器),我似乎都会得到针对项目返回的每个测试运行
例如,我知道有14个针对特定版本的测试运行
我可以通过以下查询获取我的发布id
https://smartassessor.vsrm.visualstudio.com/Smart 终点评估/_API/release/releases?searchText=release-103
如果我尝试在测试运行查询中像这样使用该id
https://smartassessor.visualstudio.com/Smart 终点评估/api/测试/运行?releaseIds=1678和api版本=5.0-preview.2
我得到了529个结果,看起来大部分测试都是针对项目运行的
过滤器是否针对该端点工作?如果是这样,我应该如何调整请求以利用releaseIds
参数
谢谢我可以复制这个问题。这些API目前似乎不可用 这是一个很好的跟踪方法。您还可以跟踪它的更新 作为一种解决方法,您可以使用下面的PowerShell脚本按版本ID筛选测试运行:(或者您可以将结果导出到*.CSV文件)
不幸的是,我无法使此代码正常工作。它只是在foreach looop
Invoke RestMethod:{“$id”:“1”,“innerException”:null,“message”:“找不到id为3925的测试运行。它可能已被删除。
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.