2014-06-18 49 views
1

我有以下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 = "[email protected]"; 
      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"); 
         } 
} 
} 

回答

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.

相關問題