Reputation: 21
Consider the below example
Feature: scenario outline using a dynamic table from a csv file
Scenario Outline: cat name: Given url demoBaseUrl And path 'cats' And request { name: '#(name)', age: '#(age)' } When method post Then status 200 And match response == { id: '#number', name: '#(name)' }
# the single cell can be any valid karate expression
# and even reference a variable defined in the Background
Examples:
| read('kittens.csv') |
If the above kittens.csv file contains 100 rows I want to read only 50 rows to execute the scenario outline .Is there any way in karate to ready only the given n rows from csv file
Upvotes: 2
Views: 297
Reputation: 58088
Since it is pure JS, any Array
operation is possible. So you can easily do this:
| read('kittens.csv').slice(0, 49) |
That said, Karate was not designed for this. You may be better off trying to do data-driven tests like this: https://stackoverflow.com/a/72388475/143475
Upvotes: 1