如何获取特定测试用例的Rally TestCaseStepReferences

如何获取特定测试用例的Rally TestCaseStepReferences,rally,Rally,我需要更新特定测试用例的测试步骤,例如:TC1020 我有下面的代码,它返回testcaseresson QueryRequest testStepRequest = new QueryRequest("TestCase"); testStepRequest.setFetch(new Fetch("TC2006", "Name", "Steps")); // testStepRequest.setQueryFilter(new QueryFilte

我需要更新特定测试用例的测试步骤,例如:TC1020

我有下面的代码,它返回testcaseresson

        QueryRequest testStepRequest = new QueryRequest("TestCase");
        testStepRequest.setFetch(new Fetch("TC2006", "Name", "Steps")); //
        testStepRequest.setQueryFilter(new QueryFilter("FormattedID", "=",
                "TC2006"));
        QueryResponse qresponse = restApi.query(testStepRequest);
输出

{ “查询结果”:{ “_rallyAPIMajor”:“2”, “_rallyAPIMinor”:“0”, “错误”:[

} }

我可以得到预期的计数为5。现在我想得到所有teststep的TestCaseStep引用(例如:) 当我复制可复制的URL浏览器时,我能够在JSON响应中看到所有5个TestStepReference

非常感谢您的帮助

问候,,
Kiran

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

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());
    }
}
JsonArray myTestCases=qresponse.getResults();
对于(int i=0;i
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());
    }
}