Testing / Karate Framework Interview questions
How do you implement data-driven testing using Scenario Outline and Examples in Karate?
A Scenario Outline paired with an Examples table is the standard way to run the same logical test against many different inputs, with each table row substituting into placeholders written in angle brackets throughout the scenario's steps.
Scenario Outline: validate login with different credentials Given url baseUrl + '/login' And request { username: '<username>', password: '<password>' } When method post Then status <expectedStatus> And match response.error == '<expectedError>' Examples: | username | password | expectedStatus | expectedError | | alice | correct | 200 | #null | | alice | wrong | 401 | Invalid credentials | | "" | correct | 400 | Username is required |
For larger or externally maintained datasets, the Examples table can also read from a CSV or JSON file instead of listing rows inline, which keeps the feature file itself readable while letting the actual test data live and be maintained separately, useful when non-technical stakeholders own the dataset.
More Related questions...