postman - Postman, Set on evraibale for "run session"
问题描述
I know that we can set a variable in different scopes via a pre-request script, but can we set one for on "execution" or "run of test".
I have a folder that contains two requests to validate a scenario where the first one will create a resource with an unique id and the second one will fail by trying to create a resource with the same unique id.
I would like to generate that unique value each time the collection is run. At this time I use a collectionVariables
to test and set when not present but that variable is kept between each "retry".
Can I create a variable that will be the same only for one execution of a collection ?
Thanks
解决方案
I have similar cases, where I store the values in Environment variables and then unset them in the Pre-request script of the first request:
pm.environment.unset("myVariable");
推荐阅读
- google-sheets - 如何用公式重塑输入数据集
- mysql - 如何在同一个表mysql中的所有其他2列中没有2列时选择行
- java - jdk.serialFilter 不适用于限制 Java 中 TreeMap 的深度(防止通过 Java 进行 DoS 攻击)
- json - 将数组作为新对象分配给 JSON 对象
- javascript - setInterval() 方法完成整个操作后如何使警报出现
- c# - 如何将类注册为接口但调用方法?
- python - 如何连接数据库并在机器人消息中打印其内容?
- java - 在 Number 的左侧添加零
- sql - 我们如何避免使用 SQL Server 在第一页列出同一类别下的产品
- python-3.x - 如何根据绘图中的条件为折线图着色?