Rally:测试用例中引用的更新测试文件夹

时间:2014-06-18 21:35:24

标签: java web-services rally

我有以下Java代码(如下)来更新我的测试用例。我想在我的测试用例中更新三个字段。这三个字段是Project,Test Folder和Notes。它工作时的代码只更新Project和Notes字段。 “测试文件夹”字段保持不变。为了让它更新我的测试文件夹字段,我需要做出哪些更改? 感谢

import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.CreateRequest;
import com.rallydev.rest.request.UpdateRequest;
import com.rallydev.rest.response.CreateResponse;
import com.rallydev.rest.response.UpdateResponse;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.CreateRequest;
import com.rallydev.rest.request.DeleteRequest;
import com.rallydev.rest.request.GetRequest;
import com.rallydev.rest.request.QueryRequest;
import com.rallydev.rest.request.UpdateRequest;
import com.rallydev.rest.response.CreateResponse;
import com.rallydev.rest.response.DeleteResponse;
import com.rallydev.rest.response.GetResponse;
import com.rallydev.rest.response.QueryResponse;
import com.rallydev.rest.response.UpdateResponse;
import com.rallydev.rest.util.Fetch;
import com.rallydev.rest.util.QueryFilter;
import com.rallydev.rest.util.Ref;
import com.rallydev.rest.util.Ref;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import com.rallydev.rest.RallyRestApi;

public class TestCaseUpdate {

        // TODO Auto-generated constructor stub
        public static void main(String[] args) throws URISyntaxException, IOException {


            String host = "https://rally1.rallydev.com";
            String username = "username@company.com";
            String password = "secret";
            String wsapiVersion = "v2.0";
            String projectRef = "/project/387xxxx.js";
            String tfRef = "/testfolder/198xxx.js";
                    //String tfRef = "/testfolders/198xxx.js";
            String applicationName = "RestExample_createTFandTC";



                    RallyRestApi restApi = new RallyRestApi(
                     new URI(host),
                     username,
                     password);
                    restApi.setWsapiVersion(wsapiVersion);
                    restApi.setApplicationName(applicationName);


            JsonObject tcUpdate = new JsonObject();
            tcUpdate.addProperty("Notes", "Fixed3");
            tcUpdate.addProperty("Project", projectRef);
            tcUpdate.addProperty("Test Folder", tfRef);
            UpdateRequest updateRequest = new UpdateRequest("/testcase/186xxx.js", tcUpdate);

            UpdateResponse updateResponse = restApi.update(updateRequest);
            if (updateResponse.wasSuccessful()) {
                System.out.println("Successfully updated test case: ");
            } else {
                            System.out.println("Error");
                        }
}
}

1 个答案:

答案 0 :(得分:0)

使用TestFolder,无空格:

tcUpdate.addProperty("TestFolder", tfRef);

您可以检查WS API对象模型,以确保对象的名称与WS API引用它们完全拼写。

无需添加.js。 WS API v2.0端点不需要.js,因为这是唯一支持的格式(不再是xml)。

String tfRef = "/testfolder/1234";

请注意,测试文件夹无法从一个项目移动到另一个项目:它们属于创建它们的项目。测试用例可以在同一工作区内从一个项目移动到另一个项目。这意味着您的项目引用应指向测试文件夹所在的项目。在UI中,如果测试用例位于项目P1内的测试文件夹TF1中,并且用户试图将测试用例移动到另一个项目P2,则会出现此错误:The selected Test Folder is not in the "P2" Project; the Test Folder must be in the same Project as this Test Case or the Parent Project.

相关问题