azure-devops - VSTS - 测试 -> 运行 -> 查询端点未根据参数进行过滤
问题描述
我正在尝试使用 Test -> Runs -> Query 端点来返回特定版本的测试运行列表,详见此处
不幸的是,无论我作为查询参数输入什么($top
似乎过滤的除外),我似乎都得到了针对项目返回的每个测试运行。
例如,我知道针对特定版本有 14 次测试运行。
我可以通过以下查询获取我的发布 ID...
https://smartassessor.vsrm.visualstudio.com/Smart End Point Assessment/_apis/release/releases?searchText=Release-103
如果我然后尝试在这样的测试运行查询中使用该 ID...
https://smartassessor.visualstudio.com/Smart End Point Assessment/_apis/test/runs?releaseIds=1678&api-version=5.0-preview.2
我得到 529 个结果,看起来大多数测试都是针对该项目运行的。
过滤器是否针对此端点工作?如果是这样,我应该如何调整我的请求以使用该releaseIds
参数。
谢谢
解决方案
我可以重现这个问题。似乎 API 暂时不可用。
此处提交了一个问题以跟踪此问题。您还可以跟踪它的更新。
作为一种解决方法,您可以使用下面的 PowerShell 脚本按版本 ID 过滤测试运行:(或者,您可以将结果导出到*.CSV文件)
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.
推荐阅读
- php - Wordpress - 读取 json 文件的速度与将其硬编码在同一个文件中的速度?
- flutter - 相同的 Style 属性在 TextSpan 和 Text 小部件中的行为不同
- sql - SQL查询带有条件的最新值
- python - 将列表与矩阵中的相似元素组合(Python)
- rest - 为什么 Kubernetes REST API 势在必行?
- animation - 移动 SVG 箭头需要正确的方向
- html - 记忆游戏:为什么翻转卡片在我的 CSS 代码中不起作用
- javascript - 对象返回错误的日期格式?
- java - 每当使用插入时主键生成器
- excel - 当列出的代码经过测试时,我得到一个对象不支持方法错误