Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Could someone help me with below : Is it possble to use json path expression in the Scenario Outline examples?

Scenario Outline:Verify the path and description

Given url
When method GET
* match <path> == <description>

Examples:
|path|description|
|$.parent.child.description|"First child"|
question from:https://stackoverflow.com/questions/66056010/how-to-use-match-while-using-examples-section-with-column

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
867 views
Welcome To Ask or Share your Answers For Others

1 Answer

Yes, see example below:

Scenario Outline:
* def response = { foo: '1', bar: '2' }
* match <path> == '<expected>'

Examples:
| path  | expected |
| $.foo | 1        |
| $.bar | 2        |

But I strongly recommend you don't try to do this kind of "clever stuff" since it leads to maintainability issues in the long term. For an example of what I am referring to, see this example: https://stackoverflow.com/a/54126724/143475

Karate is very good at matching the entire JSON in one step and you will lost that advantage. Also your example has a serious problem because it will make a GET request for every row in the table.

So please write one Scenario for each "flow" you want to test as far as possible. Do not combine things too much. I am speaking from experience :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...