Serenity + Rest Services

I'm trying to demonstrate serenity with Restassured in my workplace and show them how amazing and easy it is to use compared to using jasmine.js No matter how I get stuck in the basic tests I'm trying to do My test says

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 will I go to the next step

 @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); } 

The questions I have

  • How do I insert variables (Salbutamol, Panadol) in uri?
  • How to put this URI in a separate properties file and call it in the Step method?

Any help really appreciated Thanks

+5
source share
1 answer

RestAssured requests correspond to the same code structure that should be added to your sendRequest method:

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

The URL may come from the properties file, but you need to create a method to load it before running the test, and then you need to create the getPropety () method to get the current value that you need.

I suggest reading the official documentation here: https://github.com/rest-assured/rest-assured

+1
source

Source: https://habr.com/ru/post/1271415/


All Articles