【问题标题】:Java Rally REST API: How to create new test caseJava Rally REST API:如何创建新的测试用例
【发布时间】:2017-01-04 16:35:37
【问题描述】:

我已经能够通过 Rally API 成功创建测试结果,但现在我想创建一个测试用例(如果 Rally 中还没有测试用例)。

我收到来自 Rally 的错误消息“对象 ID 为空”,这意味着 Rally 认为我正在更新一个测试用例,即使我正在尝试创建一个测试用例。

有没有人尝试过创建测试用例 Rally API,或者有没有人看到我需要修复什么? 谢谢!

//Method to build the JSON and create the new test CASE in Rally
    public static void createNewTestCase(String currentMethodName) 
    throws URISyntaxException, IOException{
        Configuration conf = new Configuration();
        RallyRestApi restApi = new RallyRestApi(new URI(
        "https://rally1.rallydev.com"),
        {authentication code});
        restApi.setApplicationName("Test Case");             
         try {
                //Create test case
                JsonObject newTestCase = new JsonObject();
                newTestCase.addProperty("Name", currentMethodName);
                newTestCase.addProperty("Description", "Created by Rally");
                newTestCase.addProperty("Project", "Project1"));
                newTestCase.addProperty("Type", "Functional");
                newTestCase.addProperty("Method", "Automated");
                newTestCase.addProperty("DefectStatus", "NONE");
            CreateRequest createRequest = new CreateRequest("testcase",
                newTestCase);
            CreateResponse createResponse = restApi.create(createRequest);
                if (createResponse.wasSuccessful()){
                System.out.println("Test case created successfully");
                }
                else {
                System.out.println("The test case could not be created");
                String[] createErrors;
                createErrors = createResponse.getErrors();
                System.out.println("Error occurred creating Test Case: ");
                for (int i=0; i<createErrors.length;i++) {
                   System.out.println(createErrors[i]);
               }
                }

         }catch (Exception e){
                e.printStackTrace();
         }
         finally {
                restApi.close();
         }
   }

【问题讨论】:

    标签: java rest rally testcase


    【解决方案1】:

    我的猜测是设置项目的问题。 Rally 中的对象关系始终表示为 refs:/type/objectid

    newTestCase.addProperty("Project", "/project/12345");
    

    【讨论】:

    • 谢谢!我确实必须将项目对象 ID 添加为值,并且它起作用了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多