使用以下代碼我可以將測試用例添加到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個測試用例才能創建。
我還沒有使用拉力賽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