您可以添加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"
}
}
]
}