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

标签 java web-services rally

我有以下 Java 代码(如下)来更新我的测试用例。我想更新我的测试用例上的三个字段。这三个字段是项目、测试文件夹和注释。该代码在运行时仅更新“项目”和“注释”字段。测试文件夹字段保持不变。我需要进行哪些更改才能更新我的测试文件夹字段? 谢谢

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");
                        }
}
}

最佳答案

使用TestFolder,不带空格:

tcUpdate.addProperty("TestFolder", tfRef);

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

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

String tfRef = "/testfolder/1234";

请注意,测试文件夹无法从一个项目移动到另一个项目:它们属于创建它们的项目。可以将测试用例从一个项目移动到同一工作区中的另一个项目。这意味着您的项目引用应该指向测试文件夹所在的项目。在 UI 中,如果测试用例位于项目 P1 内的测试文件夹 TF1 中,并且如果用户尝试将测试用例移动到另一个项目 P2,则会出现此错误: 所选测试文件夹不在“P2”项目;测试文件夹必须与此测试用例或父项目位于同一项目中。

关于java - Rally:更新测试用例中引用的测试文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24295378/

相关文章:

web-services - Microsoft Web 服务和 CXF 客户端 : JAXB fails to understand "s:schema"

elasticsearch - 如何设置与elassandra和我自己的测试结合使用?

java - Hibernate:不区分大小写的搜索不适用于特殊字符

c# - 调用负载平衡的 Web 服务的偶发异常

java - 将分隔符插入 List<String> 的最优雅方式

java - 无法在 tomcat 上访问 webservice 出现 500 错误

java - Rally API,创建测试用例结果 - 连接关闭异常

javascript - 如何在名称动态更改时调试 Rally 2.0 app.js 文件

java - 方便放置更改日志的地方

java - 为什么在使用 OSX Jar Bundler 打包时 QuickTime QTSession.open 失败?