当前位置:网站首页>Advanced function of postman
Advanced function of postman
2022-07-24 23:49:00 【Love coriander】
Postman In addition to some functions introduced above , There are other small functions that may be useful in daily interface testing . today , Let's take stock of it , As shown below :
1. Data driven
Want to execute interface use cases in batch , We usually put the corresponding interface use cases in the same Collection in , And then through Runner Batch execution . This method is applicable when the parameters of the interface use case are fixed , But there is another problem , If each run , Interface parameters are changing , How to operate ?
Children's shoes who have carefully read the previous article may have guessed , Parameterize the variable . But this way , There is another problem , You need to set the parameters in advance every time , For example Pre-request Script Set as follows :
pm.environment.set("username","Surpass")
pm.environment.set("password","Surpass")
Use Pre-request Script Set environment variables and assign values no matter how many times they are run , In fact, it is still tested with fixed data .
Since neither of the above two methods can solve our problem , Then write the data to the file , Then read from the file is it possible ? stay Postman In fact, it also provides this way .
This file is used to store test data , It is generally called test data set
stay Postman The test data set in supports two formats csv and json
csv Format

json Format

The data format is similar to a table , The first row corresponds to the variable name , The following data corresponds to the corresponding test data
Let's take a look at the operation steps :
1、 open Run Collection Interface , Fill in the number of runs 、 Import test data set , Finally, click Run Collection

2、 The running results are as follows :

2. Regular tasks
Postman Provides a Monitor function , Support the submission of test tasks with timing function , The interface use case can be executed according to the set timer , The operation is as follows :

3. Interface dependency
Interface dependency is when executing an interface , Its data will depend on other interfaces , It is essentially a problem of interface data transmission . for example : For example, when deleting users , You must bring the corresponding token, and token Only after the user logs in .
3.1 Interface execution sequence
1. Default execution order
stay Postman The default execution order in , Yes, according to the Collection Execute the directory sequence in , From top to bottom .

2. Custom execution order
If you execute in the default directory order , Usually cannot meet their business needs , Fortunately Postman Provides a function postman.setNextRequest(“ The interface name you want to jump ”), Support jumping to the specified interface for execution . for example : After executing the interface user query , Skip interface user addition , Directly jump to execute password modification , An example is shown below :
- 1、 In the user query interface Tests Add the following code to :

- 2、 In the password modification interface Tests Add the following in :

- 3、 Check the running results as follows :

When using a custom interface to execute a sequence , The following points need to be noted :
postman.setNextRequest() Only effective when running set tests , That is to say Run Collection When it comes into effect , It does not take effect when running the interface alone
postman.setNextRequest() At run time , The interface included in the jump will be ignored during jump , If the interface after the jump still has an interface, continue to run the subsequent interface , That is, if there is an interface A/B/C/D/E/F, If the set jump condition is A->D, Then the interface sequence of final execution is A->D->E->F,B and C Interface ignored
The interface specified by jump must be located in the same Collection Inside
postman.setNextRequest() Functions don't matter Tests Where is called in the script , It's only executed at the end of the current script .
Now I invite you to join our software testing learning exchange group :【746506216】, remarks “ The group of ”, We can discuss communication software testing together , Learn software testing together 、 Interview and other aspects of software testing , There will also be free live classes , Gain more testing skills , Let's advance together Python automated testing / Test Development , On the road to high pay .
Friends who like software testing , If my blog helps you 、 If you like my blog content , please “ give the thumbs-up ” “ Comment on ” “ Collection ” One Key triple connection !
边栏推荐
- BGP related knowledge points
- [brother hero July training] day 20: search Binary Tree
- Collection of common online testing tools
- Paper notes: accurate causal influence on discrete data
- Is it safe for Guosen Securities to open a mobile account
- Architecture design of multi live shopping mall
- QT project - security monitoring system (function realization of each interface)
- Install K6 test tool
- Notes of Teacher Li Hongyi's 2020 in-depth learning series 5
- Shell echo command
猜你喜欢

JS ------ Chapter 5 functions and events

郑慧娟:基于统一大市场的数据资产应用场景与评估方法研究

Convex optimization Basics

Qt学习-利用数据库单例完成 登录匹配 + 注册 功能实现

Understanding complexity and simple sorting operation

50 places are limited to open | with the news of oceanbase's annual press conference coming!

Value driven provides the core driving force for the transformation of commercial BP - BP realization under business scenarios - Commercial BP sharing

Upload and download filask files

每周小结(*66):下一个五年
Browser cache
随机推荐
Piziheng embedded: the method of making source code into lib Library under MCU Xpress IDE and its difference with IAR and MDK
Multithreading & high concurrency (the latest in the whole network: interview questions + map + Notes) the interviewer is calm
WP wechat export chat record backup to computer
[nuxt 3] (x) runtime configuration
基于Verilog HDL的数字秒表
Use and partial explanation of QDIR class
Notes of Teacher Li Hongyi's 2020 in-depth learning series 5
Where are MySQL version numbers 6 and 7?
Opengauss kernel analysis: query rewriting
Development direction and problems of optaplanner
SQL rewriting Series 6: predicate derivation
50 places are limited to open | with the news of oceanbase's annual press conference coming!
SQLite database operation
Beisen prospectus: the advantages of the track are prominent, and integration + medium and large customers are plus points
The new version of SSM video tutorial in shangsilicon valley was released
Shell echo command
Efficiency increased by 98%! AI weapon behind operation and maintenance inspection of high altitude photovoltaic power station
Salesforce zero foundation learning (116) workflow - & gt; On flow
C language program environment and preprocessing
Branch and loop statements in C language learning