You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Azure DevOps TFS REST API获取测试点/用例/套件的历史测试运行记录?

获取指定TestPoint的历史TestResults(Azure DevOps Server 2020 Update 1.2)

问题场景

通过Test Points API:

https://dev.azure.com/{organization}/{project}/_apis/test/Plans/{planId}/Suites/{suiteId}/points?api-version=7.0

仅能获取到关联的LastTestRun和LastTestResult(最新测试数据),但需要提取指定TestPoint的非最新历史测试结果。当前采用的方案是先拉取TestPlan下所有TestRun,再逐个调用Run结果API提取对应TestPointId,但需执行7000次API调用(即使并行处理),耗时过长,且尝试用$select参数仅获取TestPointId也不被支持。

高效解决方案

1. 直接按TestPoint ID筛选历史结果

无需遍历所有TestRun,直接使用测试结果列表API,通过testPointId参数精准过滤目标TestPoint的所有历史结果:

https://dev.azure.com/{organization}/{project}/_apis/test/results?testPointId={testPointId}&api-version=7.0

该API会返回该TestPoint对应的全部历史测试记录,包含关联的TestRun信息,一次调用即可获取所需数据,彻底减少请求次数。

2. 批量查询多个TestPoint结果

如果需要同时获取多个TestPoint的历史数据,可使用testPointIds参数(多ID用逗号分隔)批量查询:

https://dev.azure.com/{organization}/{project}/_apis/test/results?testPointIds={id1},{id2},{id3}&api-version=7.0

这能进一步压缩API调用次数,提升处理效率。

3. 分页处理大量结果

若单个TestPoint的历史结果条目过多,可通过$top和$skip参数分页获取,避免单次请求返回数据量过大:

https://dev.azure.com/{organization}/{project}/_apis/test/results?testPointId={testPointId}&$top=100&$skip=0&api-version=7.0

额外说明

  • 你的Azure DevOps Server 2020 Update 1.2完全支持上述API参数(testPointId/testPointIds在API版本7.0中已实现)。
  • 如需更精细筛选,还可添加completedDateStart、completedDateEnd、outcome等参数,按时间范围或测试结果状态过滤数据。

内容的提问来源于stack exchange,提问作者Damian Jankov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 09:00:42