2017-09-01 254 views
5

我想在這裏的工作場所展示寧靜,並向他們展示它與使用jasmine.js相比使用起來有多棒和容易 在基本測試中,我試圖做 我的測試說寧靜+休息服務

Given we have valid credentials for the client using this test 
    When we try to serach for a medicine '<medicine>' 
    Then we get a valid '<perfLabel>' response with search results 
    |medicine|perflabel| 
    |Salbutamol|perflabel1| 
    |Panadol|perflabel2| 
    |Salbutamol (GA)|perflabel3| 

當我進入下一步

@When("we try to serach for a medicine '(.*)' ") 
    public void tryToSearchUsingEquals(String medicine) 
    { 
    tsApiActions.requestServiceSearchWhichEquals(medicine); 
    } 


In my Step method 



@Step 
    public void requestServiceSearchWhichEquals(String medicine) 
    { 
    host = "http://www.int.abc.com.au/api/cs/v1/terminology-service/trade-product/search-summary?offset=0&limit=20&prefLabel=eq "+medicine+"&sort=prefLabel DESC&cache=false"; 

    requestSend(host); 
    } 

的問題,我已經是

  1. 我如何將變量(Salbutamol,Panadol)注入到uri中?
  2. 如何將此URI放入單獨的屬性文件並在Step方法中調用它?

任何幫助,非常感謝 感謝

回答

1

RestAssured要求遵循哪些應該被添加到您的sendRequest將方法相同的代碼結構:

given(). 
    param("prefLabel", medicine). 
when(). 
    get(URL). 
then(). 
    body(containsString(medicine)); 

URL可以來自屬性文件,但是你需要創建一個方法在測試運行之前上傳它,然後你必須創建一個getPropety()方法來獲得你需要的當前值。

我建議在此閱讀官方文檔: