简体   繁体   English

使用Java Rally Rest API将测试用例添加到Rally中的TestSet中

[英]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. 我想使用Java Rally Rest API将测试用例(已存在于Rally的Test文件夹中)添加到新创建的测试集中。 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. 基本上,每次我想通过Rally执行测试用例时,我都需要创建新的测试集并在测试集中添加相关的测试用例(优先级高,自动/手动)。 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. 测试用例通过WSAPI中TestSet上的TestCases集合与测试集相关联。 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();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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