【问题标题】:Azure DevOps REST API for Test Case Parameters Values用于测试用例参数值的 Azure DevOps REST API
【发布时间】:2020-03-12 10:35:46
【问题描述】:

我正在尝试使用 REST API 调用测试用例参数值。 DevOps 是否有 REST API 来调用测试用例参数?

我只找到了如何调用测试用例:

GET https://{instance}/{collection}/{project}/_apis/test/Plans/{planId}/suites/{suiteId}/testcases/{testCaseIds}?api-version=5.0

发件人:Test Case REST API

【问题讨论】:

    标签: azure-devops automated-tests devops azure-devops-rest-api


    【解决方案1】:

    Test Case是工作项类型,所以可以使用Get Work Item Rest API获取参数:

    GET https://{instance}/{collection}/{project}/_apis/wit/workitems/{id}?api-version=5.0
    

    在回复中,您将在fields 部分中看到:

    Microsoft.VSTS.TCM.Parameters: "<parameters><param name='test'><value>Shayki</value></param></parameters>"
    

    【讨论】:

      【解决方案2】:

      获取参数的直接方法是在URL中添加fields=Microsoft.VSTS.TCM.LocalDataSource。像这样:

      GET https://{instance}/{collection}/{project}/_apis/wit/workitems/{id}?fields=Microsoft.VSTS.TCM.LocalDataSource&api-version=5.1
      

      Resposne 会喜欢这个

      XML 格式:

      <NewDataSet>
          <xs:schema id='NewDataSet'
              xmlns:xs='http://www.w3.org/2001/XMLSchema'
              xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'>
              <xs:element name='NewDataSet' msdata:IsDataSet='true' msdata:Locale=''>
                  <xs:complexType>
                      <xs:choice minOccurs='0' maxOccurs = 'unbounded'>
                          <xs:element name='Table1'>
                              <xs:complexType>
                                  <xs:sequence>
                                      <xs:element name='Language' type='xs:string' minOccurs='0' />
                                      <xs:element name='ItemNo' type='xs:string' minOccurs='0' />
                                      <xs:element name='Item' type='xs:string' minOccurs='0' />
                                      xs:element name='User' type='xs:string' minOccurs='0' />
                                      <xs:element name='Password' type='xs:string' minOccurs='0' />
                                  </xs:sequence>
                              </xs:complexType>
                          </xs:element>
                      </xs:choice>
                  </xs:complexType>
              </xs:element>
          </xs:schema>
          <Table1>
              <Language>EN</Language>
              <ItemNo>1234</ItemNo>
              <Item>Item1</Item>
              <User>User1</User>
              <Password>Pass1</Password>
          </Table1>
      </NewDataSet>
      

      【讨论】:

      • 非常感谢您在这里分享解决方案。您可以接受您的答案,以便其他人可以直接知道这是有效的!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多