简体   繁体   中英

Adding test cases into TestSets in rally using Java Rally Rest API

I want to add Test cases (already present in Rally in Test folders) into a newly created Test sets using Java Rally Rest API. Basically every time I want to execute the test cases through Rally I need to create new Test sets and add relevant test cases ( either priority wise, automated/ Manual) in test sets. Any help on this would be of great help.

Test cases are associated to test sets via the TestCases collection on TestSet in the WSAPI. This code example demonstrates creating a few test cases and then creating a test set associated with the newly created test cases.

RallyRestApi restApi = new RallyRestApi(new URI(SERVER),
    USERNAME, PASSWORD);

try {

    //Create some test cases
    JsonArray testCases = new JsonArray();
    for(int i = 0; i < 3; i++) {
        JsonObject newTestCase = new JsonObject();
        newTestCase.addProperty("Name", "New Test Case " + i);
        CreateRequest createRequest = new CreateRequest("testcase", newTestCase);
        CreateResponse createResponse = restApi.create(createRequest);
        String ref = createResponse.getObject().get("_ref").getAsString();
        System.out.println(String.format("Created test case %s", ref));

        //Keep track of the test case
        JsonObject testCase = new JsonObject();
        testCase.addProperty("_ref", ref);
        testCases.add(testCase);
    }

    //Create test set
    JsonObject newTestSet = new JsonObject();
    newTestSet.addProperty("Name", "New Test Set");
    newTestSet.add("TestCases", testCases);
    CreateRequest createRequest = new CreateRequest("testset", newTestSet);
    CreateResponse createResponse = restApi.create(createRequest);
    System.out.println(String.format("Created test set %s", createResponse.getObject().get("_ref").getAsString()));

} finally {
    //Release all resources
    restApi.close();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM