如何添加新的测试用例并将其与Rally中已存在的用户素材相关联

时间:2014-02-12 03:50:03

标签: rally

我使用以下代码添加新的测试用例并关联到Rally中的现有UserStory。它创建了新的测试用例,但没有与现有的用户故事US4相关联。我错过了任何引用。任何帮助都将受到高度赞赏

            String storyFormattedID = "US4";
    QueryRequest storyRequest = new QueryRequest("HierarchicalRequirement");
    storyRequest.setFetch(new Fetch("FormattedID", "Name", "Changesets"));
    storyRequest.setQueryFilter(new QueryFilter("FormattedID", "=",
            storyFormattedID));
    QueryResponse storyQueryResponse = restApi.query(storyRequest);
    JsonObject storyJsonObject = storyQueryResponse.getResults().get(0)
            .getAsJsonObject();
    String storyRef = storyJsonObject.get("_ref").toString();

    JsonObject newTestCase = new JsonObject();
    newTestCase.addProperty("Name", "Test Case");
    newTestCase.addProperty("Requirement", storyRef);
    newTestCase.addProperty("Name",
            "Newly added testcase associated to a Story");
    CreateRequest createRequest = new CreateRequest("testcase", newTestCase);
    CreateResponse response = restApi.create(createRequest);
    System.out.println(response.toString());
    JsonObject json = response.getObject();
    System.out.println(json);

1 个答案:

答案 0 :(得分:0)

TestCaseHierarchicalRequirement相关联的正确属性为WorkProduct,因为TestCases可以将其关联到HierarchicalRequirementDefect。所以:

newTestCase.addProperty("WorkProduct", storyRef);

应该为你做的伎俩。