1

I want to Pass the parameter "Country" with different countries names. Is it possible to keep all the country names in excel and call those from the datafile.

RestAssured.given()
    .pathParam("country", "Finland")
    .when()
        .get("http://restcountries.eu/rest/v1/name/{country}")
    .then()
        .body("capital", containsString("Helsinki"));
AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
Mahesh
  • 21
  • 1
  • 1
  • 5

2 Answers2

0

Rest Assured does not work with excel. What you are actually looking at is some java library like Apache POI to extract data from excel sheet.

Now your path should be

  1. Prepare all test data in excel
  2. Use Apache POI to extract values from excel to your framework
  3. Prepare query param or path param from the values extracted from excel
  4. Pass the newly built endpoint to the test method.
  5. Verify test result
0

You can use Apache POI and TestNG to achieve your goal.

For example, you can parse your data Excel sheet in a data provider method and can use that data provider in your test method as,

@Test (dataProvider = "dataSheet")
public void testCountryCapital (String country, String capital) {
    RestAssured.given()
     .pathParam("country", country)
     .when()
     .get("http://restcountries.eu/rest/v1/name/{country}")
     .then()
     .body("capital", containsString(capital));
}
Wasiq Bhamla
  • 949
  • 1
  • 7
  • 12