场景示例中的jsonPath [英] jsonPath in scenario example

查看:54
本文介绍了场景示例中的jsonPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以在下面帮助我吗: 在方案大纲"示例中可以使用json路径表达式吗?

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"|

推荐答案

是的,请参见以下示例:

Yes, see example below:

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

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

但是我强烈建议您不要尝试做这种聪明的事情",因为从长远来看,这会导致可维护性问题.有关我所指的示例,请参见以下示例: https://stackoverflow.com/a/54126724/143475

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

空手道非常擅长一步一步匹配 entire JSON,您将失去这一优势.同样,您的示例也存在严重问题,因为它将对表中的行进行GET请求.

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.

因此,请为您要测试的每个流"尽可能写一个Scenario.不要把东西太多.我是根据经验说的:)

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 :)

这篇关于场景示例中的jsonPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆