Snehith tammewar
Snehith tammewar

Reputation: 69

karate: Dynamic Scenario Outline not working when json is defined in background

Feature: Dynamic Scenario Outline
 Background: 
  * def kittens = [{"name":"abc"},{"name":"def"}]
 Scenario Outline: cat name: <name> 
  * print <name> 
 Examples: 
  | kittens |

error after executing this code is:

 org.graalvm.polyglot.PolyglotException: ReferenceError: "kittens" is not defined

Whereas, if I put this JSON directly into examples, this is working and executing 2 time. passing as shown below:

Examples: 
  | [{"name":"abc"},{"name":"def"}] |

why am i getting "kittens" is not defined, any idea?

Upvotes: 1

Views: 1108

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58088

The Background does not work like this in new versions of Karate.

Please read: https://github.com/karatelabs/karate/releases/tag/v1.3.0

So try:

Feature:

@setup
Scenario:
* def kittens = [{"name":"abc"},{"name":"def"}]  

 Scenario Outline: cat name: <name> 
  * print name 
 Examples: 
  | karate.setup().kittens |

Upvotes: 2

Related Questions