当前位置:网站首页>Getting started with postman -- built-in dynamic parameters, custom parameters and assertions
Getting started with postman -- built-in dynamic parameters, custom parameters and assertions
2022-07-03 21:02:00 【Little brother said test】
One 、postman Built in dynamic parameters and custom dynamic parameters
1、 Built in dynamic parameters
{ {$timestamp}} Generate current timestamp
{ {$randomInt}} Generate 0~1000 random number
{ {$guid}} Generate a GUID Long string random number
2、 Custom dynamic parameters
stay Pre-request Script
Define parameters in , Then set it as a global variable , And can realize custom dynamic parameters , For example, create a user tag interface , Except for access_token Outside , Transmitted name
Value cannot be duplicate , At this time, we can use { {$timestamp}}
Outside the timestamp tag 【 Be careful , This is a little bad , We don't know that the timestamp is in advance , There are drawbacks in making assertions 】 You can also use custom dynamic parameters .
adopt
Defined a times
Variable . The method of calling custom variables is { { Variable name }}
, There is no need to add the dollar sign .
Two 、postman General assertion 、 Dynamic parameter assertion 、 Global assertion
The assertion should be written in Tests
In the TAB. ,postman Many assertion methods have been provided to us , It's all on the right
Call directly when using , For example, we are getting access_token The interface makes the following assertions
The first is the status code 200;
The second assertion is that the returned string contains access_token character string
stay Tests
Tab cannot be passed { { Variable name }} Method to call global variables , Only through :
1)postman Its own method of obtaining global variables pm.global.get(" Variable name ")
First get , Call again
2)globals[" Variable name "]
3)globals. Variable name
Call in the above three ways
Whether the assertion passes , Will be in Test Results It shows that
Like the status code is 200 This assertion should be the assertion that every use case should make , But if every use case is written once, it's a little bit like Automation , At this time, you can make a global assertion , That is, every use case will judge
for example , We didn't write any assertions in the query tag , But the status code will be carried out after execution 200 The judgment of the :
The first is the status code 200;
The second assertion is that the returned string contains access_token character string
stay Tests
Tab cannot be passed { { Variable name }} Method to call global variables , Only through :
1)postman Its own method of obtaining global variables pm.global.get(" Variable name ")
First get , Call again
2)globals[" Variable name "]
3)globals. Variable name
Call in the above three ways
Whether the assertion passes , Will be in Test Results It shows that
Like the status code is 200 This assertion should be the assertion that every use case should make , But if every use case is written once, it's a little bit like Automation , At this time, you can make a global assertion , That is, every use case will judge
for example , We didn't write any assertions in the query tag , But the status code will be carried out after execution 200 The judgment of the :
The following is the supporting information , For doing 【 software test 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you !
Last : It can be in the official account : Programmer Xiaohao ! Get a free copy of 216 Page software testing engineer interview guide document information . And the corresponding video learning tutorial is free to share !, It includes basic knowledge 、Linux necessary 、Shell、 The principles of the Internet 、Mysql database 、 Special topic of bag capturing tools 、 Interface testing tool 、 Test advanced -Python Programming 、Web automated testing 、APP automated testing 、 Interface automation testing 、 Testing advanced continuous integration 、 Test architecture development test framework 、 Performance testing 、 Safety test, etc. .
If my blog helps you 、 If you like my blog content , please “ give the thumbs-up ” “ Comment on ” “ Collection ” One button, three links ! Friends who like software testing , You can join our testing technology exchange group :779450660 There are various software testing resources and technical discussions )
边栏推荐
- In 2021, the global general crop protection revenue was about $52750 million, and it is expected to reach $64730 million in 2028
- Sightseeing - statistics of the number of shortest paths + state transfer + secondary small paths
- Cannot load driver class: com. mysql. cj. jdbc. Driver
- 一台服务器最大并发 tcp 连接数多少?65535?
- 如临现场的视觉感染力,NBA决赛直播还能这样看?
- Line segment tree blue book explanation + classic example acwing 1275 Maximum number
- Phpexcel import export
- MySQL master-slave synchronization principle
- Qualcomm platform WiFi update disconnect end open event
- Quickly distinguish slices and arrays
猜你喜欢
强化学习-学习笔记1 | 基础概念
Etcd 基于Raft的一致性保证
你真的知道自己多大了吗?
Node MySQL serialize cannot rollback transactions
It is discussed that the success of Vit lies not in attention. Shiftvit uses the precision of swing transformer to outperform the speed of RESNET
Apprentissage intensif - notes d'apprentissage 1 | concepts de base
Advanced collaboration: coroutinecontext
Scientific research document management Zotero
2022 melting welding and thermal cutting examination materials and free melting welding and thermal cutting examination questions
Preliminary practice of niuke.com (11)
随机推荐
Strange way of expressing integers (expanding Chinese remainder theorem)
"Actbert" Baidu & Sydney University of technology proposed actbert to learn the global and local video text representation, which is effective in five video text tasks
LabVIEW training
Haven't expressed the artifact yet? Valentine's Day is coming. Please send her a special gift~
Install and use Chrony, and then build your own time server
同花顺开户注册安全靠谱吗?有没有风险的?
Qt6 QML Book/Qt Quick 3D/基础知识
Set, weakset, map, weakmap in ES6
强化学习-学习笔记1 | 基础概念
XAI+网络安全?布兰登大学等最新《可解释人工智能在网络安全应用》综述,33页pdf阐述其现状、挑战、开放问题和未来方向
The "boss management manual" that is wildly spread all over the network (turn)
Deep search DFS + wide search BFS + traversal of trees and graphs + topological sequence (template article acwing)
Link aggregation based on team mechanism
Cannot load driver class: com. mysql. cj. jdbc. Driver
C 10 new feature [caller parameter expression] solves my confusion seven years ago
2022 safety officer-c certificate examination and safety officer-c certificate registration examination
强化學習-學習筆記1 | 基礎概念
Kubernetes 通信异常网络故障 解决思路
浅析 Ref-NeRF
Refer to some books for the distinction between blocking, non blocking and synchronous asynchronous