当前位置:网站首页>Getting started with postman
Getting started with postman
2022-06-26 10:43:00 【Erlin likes meat】
Catalog
postman Basic knowledge required for interface testing
Postman Auto generate script language
Postman The page layout

PS: Different versions Postman The interface is slightly different , But each icon The meaning of has not changed much
Upper menu bar :
Runner Run collection request
Add New page
Sender icon Grab api request
Wrench icon Set up
Left menu bar :
Filter filter
History Record request , In days
Collections You can use items as sets , Easy to manage
Intermediate request bar :
Request method : Include get post put delete etc.
Request address : Including the agreement 、 domain name 、 Address of the interface
Params and get Use it together
Send send and download
Save Save request
The middle part :
Authorization: authentication
Headers: Request header
Body: Request body
Pre-request Script Request pre script
Tests : Assertion
Cookies : Management request related cookies
Lower status bar :
Hide the left menu bar
Search for
Console—— Display output results
Last request
Change the display mode —— about 、 Switch up, down and back
postman Basic knowledge required for interface testing
Necessary conditions for interface test :
- Address of the interface
- agreement
- Request mode
- Request header
- Request parameters
Common request methods :
GET
POST
PUT
PATCH
DELETE
Format of parameter transfer :
- Request body submission

Form submission

Collection runner How to run the test set
Select test set
Choose a test environment
Set the number of iterations iterations
Set the interval between interfaces delay
Show request log all fail
Select parameters data file

Postman Interface Association
Connection way :
Set the environment variable
Set global variables
Tests Set a variable
Set a variable : stay pre-request scripts in , Choose the one below set variable

Then rewrite it as needed variable_key&variable_value

Can be scripted , Set up directly :
pm.globals.set("variable_key", "variable_value");
pm.collectionVariables.set("variable_key", "variable_value");
pm.environment.set("variable_key", "variable_value");
Global variables are used in any environment , Still no environment It's OK to use it in . But in different environments, you can only use environment variables inside your own environment , You cannot use other environment specific environment variables .
Use tests Assert setting variables ,cookies and session Return header present ,token There is a return body , Return to the message .
Log in and return to token, obtain token
stay tests in , Write the following statement :
// Get response data json object
var Data = pm.response.json();
// Extract... From the response data token
var test = Data.token;
// Set up token For environment variables
pm.environment.set("token", test);
Postman Response assertion
postman Several ways to respond to assertions
Response body:contains string Verify whether the returned result contains a character
Response body:is equal to a string Check the return result ( Whole ) Whether it is equal to the string
Response body:JSON value check Verify whether a field value in the returned result is equal to a value
Response header:content-type header check Verify whether the response header contains a string
Response time is less than 200ms Verify that the response time is less than 200ms
Status code:code is 200 Check whether the response header contains a value

pm.test("Body matches string", function () {
pm.expect(pm.response.text()).to.include("string_you_want_to_search");
});
pm.test("Your test name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.value).to.eql(100);
});
pm.test("Body is correct", function () {
pm.response.to.have.body("response_body_string");
});
pm.test("Content-Type is present", function () {
pm.response.to.have.header("Content-Type");
});
pm.test("Response time is less than 200ms", function () {
pm.expect(pm.response.responseTime).to.be.below(200);
});
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
Postman A parameterized
Main file formats :txt json csv
Store data as txt csv json In file , have access to runner The introduction of the file , Conduct mass testing
Be careful TXT Import format :
The first line refers to the variable name , Then each line is the corresponding value , Use English commas in the middle

Postman random number
Using random numbers can be used in mass testing and automated testing , When transferring parameters to the same parameter that cannot be repeated , Ensure that the parameters are not repeated .

Postman The monitor

It can be tested regularly , And send the test results to the email .

Postman Auto generate script language
code- Choice language - Copy

Reference material
边栏推荐
猜你喜欢

Express (I) - easy to get started

MySQL 9th job - connection Query & sub query

Basic string operations in C

Renesas electronics launched a complete intelligent sensor solution for Internet of things applications

瑞萨电子面向物联网应用推出完整的智能传感器解决方案
![Installer MySQL sous Linux [détails]](/img/38/77be56c3ef3923ce4c4e5df4a96f41.png)
Installer MySQL sous Linux [détails]

MySQL 12th job - Application of stored procedure

Linux下安裝Mysql【詳細】

Record the handling of oom problems caused by too many threads at one time

Cmake / set command
随机推荐
Is it safe to use flush mobile phones to speculate in stocks? How to fry stocks with flush
How to change the QR code material color of wechat applet
看我在Map<String, String>集合中,存入Integer类型数据
Swiftui development experience: data layer of application design for offline priority
基础-MySQL
MySQL seventh job - update data
工程数学概率论统计简明教程第二版复习大纲
What are the symbolic and direct references of the JVM
Global and Chinese market of electronic pet door 2022-2028: Research Report on technology, participants, trends, market size and share
MySQL第十一作業-視圖的應用
Progressive Web 应用程序PWA是应用程序开发的未来
Solution to the problem of compilation error due to repeated third-party package names
【软件项目管理】期末复习知识点整理
Establishment of smart dialogue platform for wechat official account
VS或Qt编译链接过程中出现“无法解析的外部符号”的原因:
Reshape a two-dimensional array with 3 rows and 3 columns to find the sum of the diagonals
SQL Server 基础介绍整理
Basic string operations in C
Global and Chinese markets of children's electronic thermometers 2022-2028: Research Report on technology, participants, trends, market size and share
MySQL项目7总结