如何通过自动化在现有测试运行中添加测试用例

时间:2017-11-07 11:40:48

标签: rally

我在测试集上创建了,我想在现有的测试运行中添加测试用例。我使用更新请求添加测试用例,但是它在测试运行中删除现有的测试用例并添加它。

if(!testCaseList.isJsonNull()&&!update){
            restApi.setApplicationName("PSN")
            JsonObject newTS = new JsonObject()
            newTS.addProperty("Name", TSName)
            newTS.addProperty("PlanEstimate", points)
            newTS.addProperty("Project", projectRef)
            newTS.addProperty("Owner", userRef)
            if (releaseRef!="") newTS.addProperty("Release", releaseRef)
            if (iterationRef!="") newTS.addProperty("Iteration", iterationRef)
            newTS.add("TestCases", testCaseList)
            CreateRequest createRequest = new CreateRequest("testset",newTS)
            CreateResponse createResponse = restApi.create(createRequest)
            ref = createResponse.getObject().get("_ref").getAsString()
        }
        else if(!testCaseList.isJsonNull()&&update){
            restApi.setApplicationName("PSN")
            newTS.addProperty("Name", TSName)
            newTS.addProperty("PlanEstimate", points)
            newTS.addProperty("Project", projectRef)
            newTS.addProperty("Owner", userRef)
            if (releaseRef!="") newTS.addProperty("Release", releaseRef)
            if (iterationRef!="") newTS.addProperty("Iteration", iterationRef)
            newTS.add("TestCases", testCaseList)
            UpdateRequest updateRequest = new UpdateRequest(ref,newTS)
            UpdateResponse updateResponse = restApi.update(updateRequest)
            ref = updateResponse.getObject().get("_ref").getAsString()

        }

1 个答案:

答案 0 :(得分:1)

您不想直接设置TestCases集合,而是希望使用CollectionUpdateRequest和updateCollection方法。

https://github.com/RallyTools/RallyRestToolkitForJava/wiki/User-Guide#update-collection

CollectionUpdateRequest testsetTestCasesAddRequest = new CollectionUpdateRequest(ref + "/testcases", testCaseList, true);
CollectionUpdateResponse testsetTestCasesAddResponse = restApi.updateCollection(testsetTestCasesAddRequest);