您可以添加Visual Studio的測試任務後Powershell的任務。在PowerShell任務中:
- 通過Timeline REST API獲取以前的構建任務的詳細信息。
- 然後通過名稱,如
VsTest - testAssemblies
搜索Visual Studio的測試任務。
- 檢查是否爲
message
值的參數是no tests discovered
(或No results found to publish
等)問題的一部分。如果有這樣的值,請在PowerShell任務中添加命令exit 1
以使構建失敗。
爲Visual Studio測試任務的輸出示例顯示如下消息No results found to publish
:
{
"id": "29b3a87c-3c5b-473f-9ab5-85eff906250e",
"parentId": "299295b6-d397-492c-958e-094ec90630f8",
"type": "Task",
"name": "VsTest - testAssemblies",
"startTime": "2017-08-08T07:37:16.18Z",
"finishTime": "2017-08-08T07:37:23Z",
"currentOperation": null,
"percentComplete": null,
"state": "completed",
"result": "succeeded",
"resultCode": null,
"changeId": 13,
"lastModified": "0001-01-01T00:00:00",
"workerName": "name",
"order": 6,
"details": null,
"errorCount": 0,
"warningCount": 2,
"url": null,
"log": null,
"task": {
"id": "ef087383-ee5e-42c7-9a53-ab56c98420f9",
"name": "VSTest",
"version": "2.0.70"
},
"issues": [
{
"type": "warning",
"category": "General",
"message": "",
"data": {
"type": "warning",
"code": "002003"
}
},
{
"type": "warning",
"category": "General",
"message": "No results found to publish.",
"data": {
"type": "warning"
}
}
]
}