查询参数的默认值 [英] Default values for query parameters

查看:66
本文介绍了查询参数的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的问题没有道理,请原谅我.

Please forgive me if my question does not make sense.

我想做的是为查询参数注入值

What im trying to do is to inject in values for query parameters

GET1 File
Scenario:

Given path 'search'
And param filter[id] = id (default value or variable from another feature file)

POST1 File
Scenario:
def newid = new id made by a post call
def checkid = read call(GET1) {id : newid}

就像如果我的功能文件之一创建了一个新的ID,那么我想在上述情况下进行一次get调用.因此,我需要在其中输入新ID的参数.

like if one of my feature files creates a new id then i want to do a get call with the above scenario. therefore i need a parameter there which takes in the new id.

另一方面,如果我没有新创建的ID或创建它的测试不属于套件.我希望仍然能够运行上述方案,但是这次它具有默认值.

On the other hand if i do not have an id newly created or the test creating it is not part of the suite. i want to still be able to run the above mentioned scenario but this time it has a default value to it.

推荐答案

代替 param 使用 params .它的设计目的是忽略具有空值的任何键.

Instead of param use params. It is designed so that any keys with null values are ignored.

在下面的第一行设置 null 后,您可以进行 调用 到另一个功能,并覆盖 criteria 的值.如果仍然为 null ,则不会设置任何参数.

After the null is set on the first line below, you can make a call to another feature, and overwrite the value of criteria. If it still is null, no params will be set.

* def criteria = null
Given path 'search'
And params { filter: '#(criteria)' }

还有多种其他方法可以执行此操作,也可以参考以下示例来了解数据驱动的搜索参数:

There are multiple other ways to do this, also refer to this set of examples for data-driven search params: dynamic-params.feature

条件逻辑上的文档可能还会给您一些想法.

The doc on conditional logic may also give you some ideas.

这篇关于查询参数的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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