当前位置:网站首页>Postman -- use
Postman -- use
2022-07-02 10:23:00 【Lost ~ know to return】
postman- The interface test
- Introduction and classification of interface testing
- Interface testing process and use case design
- POSTMAN Perform interface tests
- postman Environment and global variables
- Interface Association :
- Postman Built in dynamic parameters and customized dynamic parameters in
- postman The assertion of
- postman Batch run test cases
- csv Document and json Handling of documents
- Must have an interface with a request header
- postman Interface Mock Service The server
- postman Of Cookie authentication
- Newman
- postman+Newman+jenkins Implementing continuous integration
- Interface test protocol
Introduction and classification of interface testing
Interface test is a kind of test between system components
Excuse is a service provided by software to the outside , Used for data transmission
classification :
External interface : Test the interface between the tested system and the external system
Internal interface : Internal interfaces are only provided for internal interfaces ( Just test the positive example )
Internal interfaces are provided for external interfaces ( Full test )
Why software needs interfaces ?
Because the interface allows internal data to be modified externally
Why do interface tests :
Many systems are front end and rear end separated , The development progress is different , The interface developed at the beginning needs to be tested ,mock
Interface test essence : It is to test whether the interface can interact with data normally , Access control and exception scenarios
Interface testing process and use case design
Get api file , Get it through the bag grabbing tool , Familiar with interface business , Address of the interface , Authentication method , Enter the reference , The ginseng , Error code
Write use cases for interfaces , review
Example :
Input positive reference , The interface can return normally
Counter example :
The authentication code is empty , Authentication code error , The authentication code has expired
Parameter counter example :
The parameter is empty. , Wrong parameter type , Parameter length anomaly
Error code :
Other error scenarios :
Interface blacklist , Interface call times limit , Paging scene
Hello ! This is the first time you use Markdown Editor The welcome page shown . If you want to learn how to use Markdown Editor , You can read this article carefully , Get to know Markdown Basic grammar knowledge of .
POSTMAN Perform interface tests
Request page
params:get Request parameters
Body:post Request parameters
none: No parameters
form-data: Key value pairs can also support file transfer
x-www-form-urlencoded: Key value vs. parameter
raw:json,text,xml,html,js
binary: Pass parameters in binary mode
pre-request-script: Script before request
Tests: Assertion after request
cookies: Used to manage cookie Information
Cookie: Responsive cookie Information
Header: Response head
Test Result: assertion results
200: Status code
OK: State information
681ms: Interface response time
343B: Number of response sub sections
Response tab
Body: The data returned by the interface
Pretty: With json,xml.html Different formats return data information
Raw: View the returned data as text
PreView: View the corresponding data in the form of web pages
Interview questions :
Get and Post Differences in requests
1、get The request is to get data ,post Request general submission data
2、post Request ratio get Request security
The essential difference is that the way of parameter transmission is different ,:
get The transmission parameter is followed by ? Pass parameters in the same way , Between multiple parameters & link
post Request in body In the form of a form
problem :
Multiple environments , development environment , Test environment , Production environment
Interface Association : Manual association is required
Parameters need to be modified manually
postman Environment and global variables
environment variable : Environment variables are global variables
Global variables : Variables that can be accessed in any interface
Gets the values of environment variables and global variables : adopt **{ { Variable name }}**
Interface Association :
json The extractor implements Interface Association
First interface , Generate global variables
//json To extract access_token Value
// Convert the returned string format data into the form of an object
var result = JSON.parse(responseBody);
console.log(result.access_token)
// Will get access_token Set to global variable
pm.globals.set("access_token", result.access_token);
The second interface : adopt {
{
Variable name }} call
Through regular expressions
The regular expression extractor implements interface correlation
First interface
// The regular expression extractor implements interface correlation , Represents a match
var result = responseBody.match(new RegExp('"access_token":"(.*?)"'))
console.log(result[1])
// Set to global variable
pm.globals.set("access_token", result[1]);
The second interface
{
{
access_token}}
Postman Built in dynamic parameters and customized dynamic parameters in
postman Built in dynamic parameters , Value method :
shortcoming : Cannot make assertions
{
{
$timestamp}} Generate timestamp of current time
{
{
$randomint}} Generate 0-1000 Random number between
{
{
$guid}} Generate a random guid character string
Custom dynamic parameters are set between requests
pre-request-script: Script before request
// Get the current timestamp manually
times = Date.now();
// Set to global variable
pm.globals.set("times", times);
postman The assertion of
Status code:Code is 200
Response body:Contains string : Check that the response character also contains the specified string
Response body:json value check : Checking response json Value
Response body:is equal to a string : Check that a response string is equal to
Response headers:Content-Type header check : Check whether the response contains a response header
Response time is less 200ms : Check request takes less than 200ms
Get custom parameters in assertions
- Global variables
pm.test(" The check response contains the tag name ", function () {
pm.expect(pm.response.text()).to.include(" Tyrant " + pm.globals("times"));
});
Global assertion
postman Batch run test cases
Save the file to the working directory
csv Document and json Handling of documents
csv file
1、 establish csv file ,
2、nopad++ open csv file , Write data files
3、 Change the parameter to { {key value }}
4、 Modify assertion
5、 modify access_token
6、 Run test cases ,csv How to select files
json
data format ,
establish json File format , Write data as follows
[{
"grancd_text":"chuihcuie","appname":"hjiioiojvioa","secret":"xxxxxxcccccxxxx","access_v":"jjioejionojo756790u90xxx"},{
"grancd_text":"hioioa","appname":"jshdich","secret":"xxxxxxcccccxxxx","access_v":"nfihihia"},
{
"grancd_text":"bdjkchi","appname":"hcuihi9","secret":"xxxxxxcccccxxxx","access_v":"fghj789uhghjb"}]
function
Must have an interface with a request header
Host Requested host address
Connection How to connect
Accept The data format received by the client
X-Request-With Asynchronous requests
User-Agent User type of client
Referer source
Cookie Cookie Information
Content-Type Format of request content
postman Interface Mock Service The server
mock simulation
The back-end interface has not been developed , The front-end business needs to call the back-end interface
postman Of Cookie authentication
What is? cookie
cookie Authentication principle
When the client accesses the server for the first time , Then the server will generate Cookie Information , And respond to the header set-cookie It's generated inside cookie The message is sent to the client
When the client first 2-N When accessing the server for the first time , Then the client will be in the request header cookie close cookie Information , So as to realize authentication
cookie The classification of :
conversation cookie: Save in memory , The downtime will be cleared automatically after the browser is closed
persistent cookie: Save on hard disk , The browser will not clear after closing , Only when the expiration time is up will it be cleared automatically
token authentication
Newman
postman It is designed for interface testing .
newman Usage method :
Export use cases , Everywhere environment , Export global variables , Test data
postman+Newman+jenkins Implementing continuous integration
1、 New projects
2、 Set up a custom workspace
3、 perform windows Batch command for
Interface test protocol
1、webservice agreement : Address of the interface :http://…?wsdl
soap agreement ,wsdl
restful The rules
get get data ,post Submit data ,put Modifying data ,delete Delete data
边栏推荐
- ERROR 1118 (42000): Row size too large (> 8126)
- Mysql索引
- 阿里云Prometheus监控服务
- [ue5] blueprint making simple mine tutorial
- [Yu Yue education] University Physics (Electromagnetics) reference materials of Taizhou College of science and technology, Nanjing University of Technology
- AutoCAD - layer Linetype
- 【教程】如何让VisualStudio的HelpViewer帮助文档独立运行
- 【虚幻】自动门蓝图笔记
- Message mechanism -- getting to know messages and message queues for the first time
- Understand the composition of building energy-saving system
猜你喜欢
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
Brief analysis of edgedb architecture
Junit5 supports suite methods
[unreal] key to open the door blueprint notes
【虚幻】按键开门蓝图笔记
【虚幻】过场动画笔记
Alibaba cloud SMS service
Alibaba cloud SLS log service
Summary of demand R & D process nodes and key outputs
虚幻材质编辑器基础——如何连接一个最基本的材质
随机推荐
2021-09-12
【教程】如何让VisualStudio的HelpViewer帮助文档独立运行
Aiphacode is not a substitute for programmers, but a tool for developers
Spatial interpretation | comprehensive analysis of spatial structure of primary liver cancer
Postman--使用
ue虛幻引擎程序化植物生成器設置——如何快速生成大片森林
What wires are suitable for wiring on bread board?
【Unity3D】无法正确获取RectTransform的属性值导致计算出错
Blender体积雾
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
[Yu Yue education] University Physics (Electromagnetics) reference materials of Taizhou College of science and technology, Nanjing University of Technology
webUI自动化学习
Mysql索引
Network communication learning
阿里云ack介绍
C language: making barrels
Delivery mode design of Spartacus UI of SAP e-commerce cloud
[leetcode] sword finger offer 53 - I. find the number I in the sorted array
Alibaba cloud SLS log service
[illusory] weapon slot: pick up weapons