首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获得特定TestCase的Rally TestCase

如何获得特定TestCase的Rally TestCase
EN

Stack Overflow用户
提问于 2014-03-13 11:22:17
回答 1查看 152关注 0票数 0

我有一个需求,需要更新特定TestCase ex的测试步骤:TC1020

我有以下代码,它返回我的TestCaseResopnse

代码语言:javascript
复制
        QueryRequest testStepRequest = new QueryRequest("TestCase");
        testStepRequest.setFetch(new Fetch("TC2006", "Name", "Steps")); //
        testStepRequest.setQueryFilter(new QueryFilter("FormattedID", "=",
                "TC2006"));
        QueryResponse qresponse = restApi.query(testStepRequest);

输出

{ "QueryResult":{ "_rallyAPIMajor":"2","_rallyAPIMinor":"0",“错误”:[

代码语言:javascript
复制
],
"Warnings": [
  "It is no longer necessary to append \".js\" to WSAPI resources."
],
"TotalResultCount": 1,
"StartIndex": 1,
"PageSize": 200,
"Results": [
  {
    "_rallyAPIMajor": "2",
    "_rallyAPIMinor": "0",
    "_ref": "https://us1.rallydev.com/slm/webservice/v2.0/testcase/17577048802",
    "_refObjectUUID": "cd9b3b44-9f56-40fc-a486-3149479786a9",
    "_objectVersion": "6",
    "_refObjectName": "Emp_DataCorrectness_AllUnmatched",
    "Name": "Emp_DataCorrectness_AllUnmatched",
    "Steps": {
      "_rallyAPIMajor": "2",
      "_rallyAPIMinor": "0",
      "_ref": "https://us1.rallydev.com/slm/webservice/v2.0/TestCase/17577048802/Steps",
      "_type": "TestCaseStep",
      "Count": 5
    },
    "_type": "TestCase"
  }
]

}}

我可以得到5的计数,这是预料中的。现在,我想获得所有测试步骤的TestCaseStep引用(例如:https://us1.rallydev.com/slm/webservice/v2.0/testcasestep/17577048860),当我复制可访问的URL浏览器时,我能够在JSON响应中看到所有5 TestStepReference。现在我想通过RestAPI来实现它。

任何帮助都是非常感谢的。

你好,基兰

EN

回答 1

Stack Overflow用户

发布于 2014-03-13 18:12:17

在WSAPI 2.0中,由于性能原因,不再返回对象的子集合,需要进行后续查询才能获得它们。因此,您需要执行如下操作:

代码语言:javascript
复制
JsonArray myTestCases = qresponse.getResults();

for (int i=0; i<myTestCases.size(); i++) {
    JsonObject testCase = myTestCases.get(i).getAsJsonObject();
    QueryRequest testStepRequest = new QueryRequest(testCase.getAsJsonObject("Steps"));
    testStepRequest.setFetch(new Fetch("StepIndex", "Input", "ExpectedResult"));
    JsonArray testCaseSteps = restApi.query(testStepRequest).getResults();
    for (int j=0;j<testCaseSteps.size();j++){                       
        System.out.println(
            testCaseSteps.get(j).getAsJsonObject().get("StepIndex").getAsString() + ": " + 
            testCaseSteps.get(j).getAsJsonObject().get("Input").getAsString() + ":" + testCaseSteps.get(j).getAsJsonObject().get("ExpectedResult").getAsString());
    }
}

在这个答案中有一个更彻底的解释:

Migrating from Rally API 1.43 to 2.0 - Object Model

其中的示例是从一个TestCases获取一个TestSet集合,但是这个过程完全类似。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22377046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档