检查我的测试计划在管道执行中是否有失败的测试用例
Check if my test plan has a failed test case in the pipeline execution
在 azure devops 中执行我的管道时,如何检查我的测试计划中是否有任何测试用例失败?
How can I check if I have any test cases failing within my test plan when executing my pipeline in azure devops?
在测试计划中,测试用例没有结果状态(例如失败通过..)。结果状态针对 Test Plan -> Execute tab
.
中的测试点
要检查测试计划中是否有失败的测试点,您可以使用 PowerShell 任务 运行 其余 API: Test Point - Get Points and Test Suites - Get Test Suites For Plan.
$token = "PAT"
$url1 = " https://dev.azure.com/{OrganizationName}/{ProjectName}/_apis/test/Plans/{TestPlanId}/suites?api-version=5.0"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$response1 = Invoke-RestMethod -Uri $url1 -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json
$i = 0
ForEach ($SuitId in $response1.value.id )
{
$url="https://dev.azure.com/{OrganizationName}/{ProjectName}/_apis/testplan/Plans/{TestPlanName}/Suites/$($SuitId)/TestPoint?api-version=6.0-preview.2"
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json
ForEach( $outcome in $response.value.results.outcome )
{
echo $outcome
if($outcome -eq "failed")
{
$i ++
}
}
}
echo $i
if ($i -eq 0)
{
echo "No error"
}
else
{
echo "##vso[task.logissue type=warning]the error value is $i"
}
结果:
在 azure devops 中执行我的管道时,如何检查我的测试计划中是否有任何测试用例失败?
How can I check if I have any test cases failing within my test plan when executing my pipeline in azure devops?
在测试计划中,测试用例没有结果状态(例如失败通过..)。结果状态针对 Test Plan -> Execute tab
.
要检查测试计划中是否有失败的测试点,您可以使用 PowerShell 任务 运行 其余 API: Test Point - Get Points and Test Suites - Get Test Suites For Plan.
$token = "PAT"
$url1 = " https://dev.azure.com/{OrganizationName}/{ProjectName}/_apis/test/Plans/{TestPlanId}/suites?api-version=5.0"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$response1 = Invoke-RestMethod -Uri $url1 -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json
$i = 0
ForEach ($SuitId in $response1.value.id )
{
$url="https://dev.azure.com/{OrganizationName}/{ProjectName}/_apis/testplan/Plans/{TestPlanName}/Suites/$($SuitId)/TestPoint?api-version=6.0-preview.2"
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/json
ForEach( $outcome in $response.value.results.outcome )
{
echo $outcome
if($outcome -eq "failed")
{
$i ++
}
}
}
echo $i
if ($i -eq 0)
{
echo "No error"
}
else
{
echo "##vso[task.logissue type=warning]the error value is $i"
}
结果: