Java Rally REST API:如何创建新的测试用例



我已经能够通过 Rally API 成功创建 TEST RESULTS,但现在如果 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();
         }
   }

我的猜测是问题出在设置项目上。拉力赛中的对象关系始终表示为 refs: /type/objectid

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

相关内容

  • 没有找到相关文章

最新更新