简体   繁体   English

如何使用 Azure DevOps API 将工作项与测试结果相关联?

[英]How to associate a work item with a test result using the Azure DevOps API?

I have read through the docs , but I still cannot figure out how a custom Azure DevOps task can associate a test result with a work item programmatically .我已通读文档,但仍然无法弄清楚自定义 Azure DevOps 任务如何以编程方式将测试结果与工作项相关联。 I built a custom task that executes tests (running and executing outside Azure DevOps).我构建了一个执行测试的自定义任务(在 Azure DevOps 之外运行和执行)。 When the tests finish and the results come back, I get the list of associated work items as well.当测试完成并返回结果时,我也会得到相关工作项的列表。 I would like to call the appropriate Azure DevOps API to associate the test result with one or more work items.我想调用适当的 Azure DevOps API 将测试结果与一个或多个工作项相关联。 Any pointers would be welcome.欢迎任何指点。

Check this extension that I have created https://github.com/JanuszNowak/janono.ado.testcase.associate.cli it allows associating in automatic manner .检查我创建的这个扩展https://github.com/JanuszNowak/janono.ado.testcase.associate.cli允许以自动方式关联 Code sample:代码示例:

namespace ExampleTestProject
{
    [TestClass]
    [janono.ado.testcase.associate.Organization("janono-pub")]
    public class UnitTest1
    {
        [TestMethod]
        [janono.ado.testcase.associate.TestCase(5)] //<---
        public void TestMethod1()
        {
            //yours test method content
            //...
            //
        }
    }
}

Test Result is also a kind of work item .测试结果也是一种工作项

Thus you could use Rest API to handle this.因此,您可以使用 Rest API 来处理此问题。

  1. Use the Get Test Results REST API to get the test case from the test result that you want to link to the work item:使用获取测试结果 REST API从要链接到工作项的测试结果中获取测试用例:

  2. Use the Get Work Item REST API to get the existing relations of the work item (user story, task, etc) that you'd like to link to the test result, and determine if the test result and/or test case are already linked to the work item:使用获取工作项 REST API获取您要链接到测试结果的工作项(用户故事、任务等)的现有关系,并确定测试结果和/或测试用例是否已链接到工作项:

  3. Uses the Update Work Item REST API to link the test result and/or test case to the work item:使用更新工作项 REST API将测试结果和/或测试用例链接到工作项:

More details of the sample and code snippet please refer Tanyan Harmon's comment in this related user voice: Need ability to link Test Results back to ANY work item type, especially User Stories有关示例和代码片段的更多详细信息,请参阅此相关用户语音中的 Tanyan Harmon 评论: 需要能够将测试结果链接回任何工作项类型,尤其是用户故事

You could also follow the link shared by Matt in the comment.您还可以点击 Matt 在评论中分享的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Azure Devops 服务更新 Azure Devops 中测试用例的“区域路径” Rest API - How to update "Area Path" of a test case in Azure Devops using Azure Devops Services Rest API 如何更改 Azure DevOps 工作项中工作项的日期格式 - How to change the date format on a Work Item in Azure DevOps Work item 如何不在 azure devops 中的“创建工作项”任务中创建重复项 - How not to create duplicates in a task "Create work item" in azure devops Azure DevOps API 错误:字段 state 当工作项被“删除”时不支持“活动” - Azure DevOps API error: Field state 'Active' not supported when Work Item has been "Removed" Azure DevOps:如何使用 REST API 从 git 下载文件? - Azure DevOps: How to download a file from git using REST API? 有没有一种方法可以使用 Rest API 从 Azure 逻辑应用程序创建 Azure DevOps 工作项? - Is there a way that we can create Azure DevOps work items using Rest API from Azure Logic apps? azure-devops python 运行“create_work_item”时出错 - azure-devops python error running 'create_work_item' Azure Devops 查询以查找每天花在工作项目上的时间 - Azure Devops Query to find Daily hours spent on Work item 使用 rest api 将笔记本部署到 azure devops - deploy notebooks to azure devops using rest api Azure 运维专区 API - Azure Devops Area API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM