1
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 Answers1

2

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 |
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • working nicely if I implement a setup. but the new problem arising is, when I run this test, a total of 3 scenarios are executing two for kittens, and one for setup itself. in the report, 3 scenarios are shown, whereas I want a count of only 2 scenarios to be shown in the report. how can i handle this? – Snehith tammewar Jan 18 '23 at 07:31
  • @Snehithtammewar https://github.com/karatelabs/karate/releases/tag/v1.3.1 - and if you can, use 1.4.0.RC3 which may have more fixes – Peter Thomas Jan 18 '23 at 07:59