2
Feature: Test Type

  Background:
    * url host
    * def name = 'test_name' 
    * def label = name

  Scenario Outline: Test 2
    Given url homeLinks.groupTypesUrl
    And headers { tenant: #(tenantId), Authorization: #(authToken) }
    * def name = <name>
    * def description = <description>
    * def label = <label>
    * json data = read('path/to/file/create_group_type_request.json')

    And request data
    When method POST
    Then status 400

    Examples:
      | name     | label   | description   |
      | '\u0000' | 'label' | 'description' |
      | #(name)  | '\u0000'| 'description' |

I need to refer global name defined inside examples map. How to get that reference?

Getting Javascript evalution error when I tried to like above piece of code.

Santosh Hegde
  • 3,420
  • 10
  • 35
  • 51

1 Answers1

2

Yes, Examples do not support JS eval and variables. Use the table form and loop over it with a call to a second feature: https://github.com/intuit/karate#calling-other-feature-files

Or you can try to use a dynamic Scenario Outline by initializing the table in the background: https://github.com/intuit/karate#dynamic-scenario-outline

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248