Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

117
Views
How to repeat gherkin snippet in Karate?

I have a snippet of Gherkin that builds a JSON body and makes an API call.

I can reuse this snippet in other Karate features via:

* call read("/path/to/snippet.feature")

I have a scenario where I need to repeat this API call, so I want to run this snippet N times.

karate.repeat() exists; however, despite the name, it does not work with Karate gherkin files, or even def'ed Karate functions based on a feature file. Apparently, it only works with JS functions.

How do I repeat a call read() of another feature file an arbitrary number of times without having to explicitly repeat the line that many times? This could get unwieldy in a scenario where the number of calls needed for the scenario is more than a small few.

It seems the only solution is to re-implement that feature as a JS function, so that now I have both a Gherkin and a JS definition of the exact same functionality, which is a pattern that is begging for maintenance nightmares.

How can I call a Karate feature file multiple times in another Karate feature?

7 months ago ยท Santiago Gelvez
Answer question
Find remote jobs