简体   繁体   English

在 Azure DevOps 的测试用例中的关联自动化下添加“自动化测试类型”值

[英]Adding "Automated Test Type" value under Associated Automation within Test Case in Azure DevOps

Does anybody know how to set the "Automated Test Type" value for a Test Case in Azure DevOps?有人知道如何在 Azure DevOps 中为测试用例设置“自动化测试类型”值吗? We have UI Tests and Unit Tests, and this would be a really helpful way to distinguish them when querying for test cases.我们有 UI 测试和单元测试,这将是在查询测试用例时区分它们的一种非常有用的方法。

Note: I am not looking for the answer of how to associate automation, this is already done as per screen shot - it's specifically the highlighted field that I am enquiring about.注意:我不是在寻找如何关联自动化的答案,这已经按照屏幕截图完成 - 它特别是我正在询问的突出显示的字段。 Thanks.谢谢。

在此处输入图像描述

As a workaround, you can edit test cases through a work item query:作为一种解决方法,您可以通过工作项查询来编辑测试用例:

在此处输入图像描述

Then update Test Type and save work items:然后更新测试类型并保存工作项:

在此处输入图像描述

The result:结果:

在此处输入图像描述

You can update any field value using the REST api methods if you want to.如果您愿意,可以使用 REST api 方法更新任何字段值。 In this case you would need to know the work item ID that you are trying to update, the name of the field you want to update, and the value you want to be applied to that field.在这种情况下,您需要知道尝试更新的工作项 ID、要更新的字段的名称以及要应用于该字段的值。

I assume you know the ID of the work item you are trying to update.我假设您知道要更新的工作项的 ID。 You can get the field name of the field by calling the GET request in the REST API as follows:可以通过在REST API中调用GET请求获取该字段的字段名,如下:

https://dev.azure.com/{{organization}}/{{project}}/_apis/wit/workitems/{{workItemID}}?$expand=Relations&api-version=5.0 https://dev.azure.com/{{organization}}/{{project}}/_apis/wit/workitems/{{workItemID}}?$expand=Relations&api-version=5.0

using Postman or similar tool使用 Postman 或类似工具

This query will return all the fields of the specified work item and you can infer the field name from the return.此查询将返回指定工作项的所有字段,您可以从返回中推断字段名称。 The structure should look something like this结构应该是这样的

"fields": {
    "System.AreaPath": "Test Strategy - Research\\Training",
    "System.TeamProject": "Test Strategy - Research",
    "System.IterationPath": "Test Strategy - Research",
    "System.WorkItemType": "Test Case",
    "System.State": "Design",
    "System.Reason": "New", 

for custom fields you should see a line that is something like对于自定义字段,您应该会看到类似于

"[custom_name].[field_name]":"[value]"

You can update this value with a PATCH to the same REST endpoint but you need to create a data body with the desired field data.您可以使用 PATCH 将此值更新到相同的 REST 端点,但您需要使用所需的字段数据创建数据主体。 The sample post below was captured in Fiddler and will update the priority of a work item:下面的示例帖子是在 Fiddler 中捕获的,它将更新工作项的优先级:

PATCH https://dev.azure.com/itineris/Test%20Strategy%20- 
%20Research/_apis/wit/workitems/335392?api-version=6.0 HTTP/1.1
Host: dev.azure.com
Accept: application/json
Authorization: Basic 
OnVhMmg3NWt4MnEyc2hkbW1lamZpdG5sMmlpN3NqZ3c1Y2tqdXVsNGdob3drb3h5MnZsYWE=
Content-Type: application/json-patch+json; charset=utf-8
Content-Length: 86
[{"op":"add","path":"/fields/Microsoft.VSTS.Common.Priority","from":null,"value":"1"}]

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM