A. Sa.
A. Sa.

Reputation: 431

Karate Skip test cases read from CSV in a Scenario Outline

I'm writing data-driven-tests with Karate. My Feature has a Scenario Outline and I am using a CSV file to load the examples e.g. the test cases.

Is it possible to skip some rows in the CSV files? I don't want to call ALL the tests every time.

Upvotes: 1

Views: 1146

Answers (1)

Neodawn
Neodawn

Reputation: 1096

Let's say you have three rows and you just want to run one. You can read the csv and then filter it using JsonPath filters. The following code will run only testcase "tc02".

Sample Code:

Feature: CSV Filter

    Background:
        * def data = read('testdata.csv')
        * def data = get data[?(@.testcase=='tc02')]

    Scenario Outline: <testcase>,<desc>
        * def look = "<testcase>,<desc>"
        * print look

        Examples:
            | data |

# testdata.csv
# testcase,desc
# tc01,desc01
# tc02,desc02
# tc03,desc03

Upvotes: 1

Related Questions