09 Data Driven - biswajitsundara/Karate GitHub Wiki
Karate test scenarios can be run multiple iterations and the data can be parameterized using Scenario Outline
and Examples
Feature: Create User Background: * url 'http://dummy.restapiexample.com' Scenario Outline: Create user using data table Given path '/api/v1/create' And request {"name":,"salary":,"age": } When method POST Then status=200 Then print response Examples: | uname | usal | uage | | Parineeti | 1230 | 32 |
Please note, we can also vary the end point
and the response array
using index from the example section.
Scenario: Create user and then fetch data for the same Given path '/api/v1/create' And request {"name":"Priyanka","salary":"6000","age": "34"} When method POST Then status=200 * def result = response Given path '/api/v1/employee/' + result.data.id When method GET Then status = 200 And print response And match response.data contains {id: '#(result.data.id)'}
Please note the CSV file should have the column name exactly same as the column name mentioned in the scenario.
Scenario Outline: Create user using data from file Given path '/api/v1/create' And request {"name":,"salary":,"age": } When method POST Then status=200 Then print response Examples: | read ('./data/data-driven.csv') |