1
Scenario Outline: I have an audit type <type>
    When a request is received
    """
    {
              "elements":{  
                 "type":<type>,
                 "id":"sku-1"
              }
    """
    Examples:
        |   type    |
        |   test1   |
        |   test2   |
        |   test3   |

How to solve the above problem to replace with the values given in Examples?

Digital
  • 549
  • 1
  • 7
  • 26

2 Answers2

2

I got it worked with simple change

Scenario Outline: I have an audit type <type>
    When a request is received
    """
    {
              "elements":{  
                 "type":'<type>',
                 "id":"sku-1"
              }
    """
    Examples:
        |   type    |
        |   test1   |
        |   test2   |
        |   test3   |
Digital
  • 549
  • 1
  • 7
  • 26
1

Might be better not to use Doc String for JSON. Instead try this:

Scenario Outline: I have an audit type
    When a request is received of "<type>"

    Examples:
      | type  |
      | test1 |
      | test2 |
      | test3 |

Sorry, the response in in Ruby, not familiar with Java conversion from String to JSON object or Hashtable. I did however find this resource that might help to manage handle the JSON:

In Ruby:

When(/^a request is received of "([^"]*)"$/) do |type|
  json = eval("{'elements':{'type':'#{type}','id':'sku-1'}}")
end

First time this runs, json will be: {'elements':{'type':'test1','id':'sku-1'}}

double-beep
  • 5,031
  • 17
  • 33
  • 41
Daniel Fintinariu
  • 2,733
  • 1
  • 14
  • 16