如何找到与测试套件关联的测试计划名称?我只有测试套件 ID,但不记得该测试套件是在哪个测试计划下创建的。
我希望找到与我创建的测试套件关联的测试计划名称。
不确定您正在寻找哪种解决方案。如果这是一次性的事情,您可以这样做并从浏览器控制台运行它。
它首先获取所有测试计划。然后循环遍历它们并检查套件包含在哪个计划中
(async () => {
const organization = 'ORG_NAME';
const project = 'PROJECT_NAME';
const pat = 'DEVOPS_PAT';
const testSuiteId = 123456;
const headers = new Headers();
headers.append('Authorization', 'Basic ' + btoa(':' + pat));
headers.append('Accept', 'application/json');
const requestOptions = {
method: 'GET',
headers: headers,
redirect: 'follow'
};
try {
let plans = [];
let continuationToken = null;
do {
const url = `https://dev.azure.com/${organization}/${project}/_apis/testplan/plans?api-version=7.1${continuationToken ? `&continuationToken=${continuationToken}` : ''}`;
const response = await fetch(url, requestOptions);
const result = await response.json();
plans = plans.concat(result.value);
continuationToken = response.headers.get('x-ms-continuationtoken');
} while (continuationToken);
for (const plan of plans) {
const suiteUrl = `https://dev.azure.com/${organization}/${project}/_apis/testplan/Plans/${plan.id}/suites/${testSuiteId}?api-version=7.2-preview.1`;
const suiteResponse = await fetch(suiteUrl, requestOptions);
if (suiteResponse.ok) {
console.log(`Found Test Suite ID ${testSuiteId} in Test Plan: ${plan.name}`);
return;
}
}
console.log(`Test Suite ID ${testSuiteId} not found in any test plan.`);
} catch (error) {
console.error('There was a problem with the fetch operation:', error);
}
})();