4

使用以下代码,我可以将测试用例添加到 RALLY 中新创建的测试集中。但它只添加了测试用例列表中的前 200 个测试用例。

private static String createTestSet(RallyRestApi restApi, String TSName, String points)throws IOException, URISyntaxException {
  QueryRequest testcases = new QueryRequest("Test Case");
  testcases.setFetch(new Fetch("FormattedID", "Name", "Owner","Test Folder"));
  // All Test cases
  testcases.setQueryFilter(new QueryFilter("TestFolder.Name", "=","testFolder").and(new QueryFilter("Method", "=", "Manual")));

  testcases.setOrder("FormattedID ASC");
  QueryResponse queryResponse = restApi.query(testcases);
  JsonArray testCaseList = new JsonArray();
  if (queryResponse.wasSuccessful()) {
    System.out.println(String.format("\nTotal results: %d", queryResponse.getTotalResultCount()));
    testCaseList=queryResponse.getResults().getAsJsonArray();
  }else{
    for (String err : queryResponse.getErrors()) {
      System.err.println("\t" + err);
    }
  }

  String ref = "null";
  System.out.println("Creating TestSet: "+TSName);
  try {
    if(!testCaseList.isJsonNull()){
      restApi.setApplicationName("PSN");
      JsonObject newTS = new JsonObject();
      newTS.addProperty("Name", TSName);
      newTS.addProperty("PlanEstimate", points);
      newTS.addProperty("Project", Project_ID);
      newTS.addProperty("Release", Release_ID);
      newTS.addProperty("Iteration", Iteration_ID);
      newTS.add("TestCases", testCaseList);
      CreateRequest createRequest = new CreateRequest("testset",newTS);
      CreateResponse createResponse = restApi.create(createRequest);
      ref = createResponse.getObject().get("_ref").getAsString();
    }
  } catch (Exception e) {
    //System.out.println("Exception Caught: " + e.getMessage());
  }
  return ref;
}

尽管测试用例查询过滤器的总结果计数大于 200,但创建的测试集仅包含 200 个测试用例。

4

1 回答 1

1

@Brian 上面的评论是正确的。默认情况下,RallyRestApi.query () 只会返回一页数据(默认页面大小为 200)。 QueryResponse.getTotalResultCount () 将返回服务器上匹配的记录总数。为了获得多页数据,只需首先使用QueryRequest.setLimit () 设置您希望返回的结果数的上限。

于 2012-11-20T15:53:40.020 回答