* print Exampl" /> * print Exampl" /> * print Exampl"/>

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

732 Views Asked by At
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?

1

There are 1 best solutions below

2
Peter Thomas On BEST ANSWER

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 |