![](/img/trans.png)
[英]How to retrieve VsTest Test Plan test case id during Azure pipeline is running and use that in automation code
[英]Check if my test plan has a failed test case in the pipeline execution
在 azure devops 中執行我的管道時,如何檢查我的測試計划中是否有任何測試用例失敗?
在 azure devops 中執行我的管道時,如何檢查我的測試計划中是否有任何測試用例失敗?
在測試計划中,測試用例沒有結果狀態(例如失敗通過..)。 結果 state 用於Test Plan -> Execute tab
中的測試點。
要檢查測試計划中是否有失敗的測試點,您可以使用 PowerShell 任務運行 Rest API: 測試點 - 獲取點和測試套件 - 獲取測試套件。
$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"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.