如何在VSTS生成期间以编程方式将附件添加到测试结果? [英] How do I programmatically add attachments to test results during a build in VSTS?

查看:50
本文介绍了如何在VSTS生成期间以编程方式将附件添加到测试结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种添加自己的附件以测试结果的方法,以便在此处构建完成后可以看到它们...

I'm looking for a way to add my own attachments to test results so that I can see them after a build has completed here...

在构建期间以及测试失败之后,我想以编程方式添加这些内容.附件将是屏幕截图.

I would like to add these programmatically, during a build and after a test has failed. The attachments will be screenshots.

这可能吗?

我快速浏览了 API 参考,但这似乎与在现有测试运行"中添加附件有关,或者在构建时,该方面是用于创建构建定义并触发它们.我可能已经错过了它,但是在测试任务完成期间或之后,我找不到如何从代码中添加附件的方法.

I had a quick look at the API reference but this looked to be concerned with adding attachments to existing test 'runs', or on the build, the side was for creating build definitions and triggering them. I may have missed it but I couldn't find how to add attachments from code during or immediately after a test task had completed.

谢谢

推荐答案

一旦获得失败的测试结果ID,就可以使用

Once you get failed test result id, you could use Rest API to attach a file to test result:

POST https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results/{result}/attachments?api-version={version}
Content-Type: application/json
{
  "stream": { string },
  "fileName": { string },
  "comment": { string },
  "attachmentType": { string }
}

这篇关于如何在VSTS生成期间以编程方式将附件添加到测试结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆