karatelabs / karate

Test Automation Made Simple
https://karatelabs.github.io/karate
MIT License
8.25k stars 1.94k forks source link

Use of data table for multiple datasets in REST call #41

Closed soniawadhwa closed 7 years ago

soniawadhwa commented 7 years ago

Feature: Rest API Demo Showing use of Data table using Karate Framework

Background:

In this case have tried various options but not sure how to use these countrycodes one by one and capture the response. Can you please suggest how to use data in this case.

Thanks Sonia

satishautade commented 7 years ago

Hi Sonia,

I am not quite sure what do you mean by 'capture the response'. I am assuming you want to validate the response returned for each of those country codes. You can have another column named something like 'expected_response' and have your expected codes there. Another thing I observed in the above example is that you are trying use Examples with Scenario. Since Cucumber Examples will only work with Scenario Outline, this is expected to fail. By the way Examples are different and data tables are different.

Please find below the modified example which possibly would work for you.

Background:

Scenario Outline: Verify the API is up and running and returning the details for each country Given path , 'get', 'iso2code' When method get And status

Examples: | country_name | expected_status | | CA | 200 | | IN | 200 | | US | 200 |

ptrthomas commented 7 years ago

I think @satishautade has answered this, I also request @soniawadhwa to please go through the doc and demo examples.