1

Is it possible to generate the scenario outline definition dynamically by calling a method in karate. In the following example

Scenario Outline: Testing different combination of inputs <input>

Examples:
      | res |

suppose value of res is:

[
   input: {test: "xyz"},
   input: {test: "pqr"},
   input: {test: "abc"}
]

The actual object inside input is quite complex, just simplified it for example.

In this case I want by different scenario definition to be

Scenario Outline: Testing different combination of inputs xyz
Scenario Outline: Testing different combination of inputs pqr
Scenario Outline: Testing different combination of inputs abc

Is this possible?

Ashu
  • 77
  • 5
  • in my opinion, yes. refer linked answer. note that you can even use a function to "generate" data that will get exploded into multiple `Scenario`-s. please refer to the docs: https://github.com/karatelabs/karate#json-function-data-source – Peter Thomas Jan 15 '23 at 15:53
  • @PeterThomas yea this I got, actually my scenarios are working fine, it is exploding into multiple scenarios, just that the scenario definition shown in the console in printing like this `Scenario Outline: Testing different combination of inputs {test: "xyz"} Scenario Outline: Testing different combination of inputs {test: "pqr"} Scenario Outline: Testing different combination of inputs {test: "abc"}` I was just wondering if i can call a function here to extract the 'test' property or any other nested key in the complex object. I tried calling a function there but it was not working – Ashu Jan 16 '23 at 05:57
  • something like this `* def getNames = function() {}` `Scenario Outline: Testing different combination of inputs {call getNames res}` – Ashu Jan 16 '23 at 06:04
  • 1
    your question was confusing. so you mean the "name as it appears in the report" yes, look for this in the docs: `Scenario Outline: name is ${name.first} ${name.last} and age is ${age}` https://github.com/karatelabs/karate#scenario-outline-enhancements – Peter Thomas Jan 16 '23 at 06:24

0 Answers0