2017-01-04 11 views
1

Rally APIを使用してテスト結果を正常に作成できましたが、今ではRallyにまだテストケースがない場合は作成します。Java Rally REST API:新しいテストケースを作成する方法

"Object ID is null"というラリーからエラーが発生しました。これは、ラリーがテストケースを更新しようとしていると考えていることを意味します。

誰かがテストケースを作成するラリー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(); 
     } 
    } 

答えて

1

私の推測では、プロジェクトの設定に問題があります。ラリーのオブジェクト関係は常にrefs-/type/objectidとして表されます

newTestCase.addPropery("Project", "/project/12345"); 
+0

ありがとうございます!私は値としてプロジェクトオブジェクトIDを追加しなければならなかったし、うまくいきました! – user7375157

関連する問題