• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

189
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?

about 3 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error