1

I am trying to create a scenario where:

  Scenario Outline: Create a request
    Given print 'reason=<reason>, detail=<detail>, metainfo=<metainfo>'
    When call create_request
    Then match response.message == "#notnull"

    * call json_to_proto request
    * print 'response \n', response

    Examples:
      reason     | detail  | metainfo
      test       | Testing | { foo: bar }

My concern is metainfo is defined as a map, "metainfo": "#(karate.get('metainfo', {}))" how do I set values for it as the current logic gives me error: org.graalvm.polyglot.PolyglotException: Expect a map object but found...

Ishita
  • 109
  • 2
  • 10

1 Answers1

0

Please read this section of the docs: https://github.com/karatelabs/karate#scenario-outline-enhancements

You can use JSON like this. And note that you don't need the <foo> placeholder system. Normal variables work:

Scenario Outline: ${payload.foo}
  * match payload == { foo: 'bar' }

  Examples:
    | payload!       |
    | { foo: 'bar' } |
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • I am new to this, can you please help elaborate the example, am I supposed to set the values as: ``` Scenario Outline: Create a request Given print 'reason=, detail=, metainfo=' When call create_request Then match response.message == "#notnull" * call json_to_proto request * print 'response \n', response Examples: reason | detail | metainfo! test | Testing | { "foo": "bar" }```` – Ishita Nov 15 '22 at 08:42