2012-11-20 957 views
4

使用以下代码我可以将测试用例添加到RALLY中新创建的测试集中。 但它只添加了测试用例列表中的前200个测试用例。使用Java Rally Rest API向测试集添加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个测试用例才能创建。

+1

我还没有使用拉力赛API,但根据['QueryRequest'](https://docs.rallydev.com/javarestapi/com/rallydev/rest/request/QueryRequest.html)和[ 'QueryResponse'](https://docs.rallydev.com/javarestapi/com/rallydev/rest/response/QueryResponse.html),结果是分页的,所以默认页面限制只有200?当你调用QueryResponse.getPageSize时,你会得到什么?对不起,我不能有更多的帮助,希望这会让你走上正确的道路。但是如果他们被分页,在'QueryRequest'上设置页面大小将会解决你的问题。 – Brian

回答