当前位置:网站首页>Can Chrome browser + postman do interface testing like this?
Can Chrome browser + postman do interface testing like this?
2022-04-22 03:11:00 【hogwarts_ beibei】

If you simply divide tests into two categories , So it's client-side testing and server-side testing . The client tests include UI test , Compatibility test, etc , Server testing includes interface testing . Interface tests check the exchange of data , Transfer and control the management process , It bypasses the client , Test the server directly .
The relationship between client test and server test :

The server is very complex , Just like the Alibaba core link diagram in the figure below , Contains about 150 A component , Components interact with each other , Forming a dense back-end network .UI Testing can't cover such a complex network of component interactions , So bypass the client , Directly use the interface test to test the server .
Ali core link diagram :
Layering the various tests in the industry , Upwards , Find out bug The later it gets , cost ( Time , Human resources , Loss ) The higher the . The interface test (Service) comparison ui test , Problems can be found earlier , Faster quality feedback ; Empathy , unit testing (Unit) Compared to interface testing , Problems can be found earlier , Faster quality feedback , It costs less .
Layered testing :

Although interface testing covers a wide range , But you can't use interface testing instead of client testing .UI Testing is about the user experience , This part cannot be replaced by interface testing .
tcp/udp/http/restful/dubbo And so on
TCP The protocol is in the transport layer , A connection oriented 、 reliable 、 Transport layer communication protocol based on byte stream . Classify interface testing tools , It can be classified as follows :
- Network sniffer tool :tcpdump,wireshark
- Agent tools :fiddler,charles,anyproxyburpsuite,mitmproxy
- Analysis tools :curl,postman,chrome Devtool
As a test , Have the ability to test the interface , In the interface test , The first common tool is postman.postman It's a powerful interface testing platform , Experience friendly visual interface , It is often used as an interface debugging tool in research and development , And manual interface testing tools for testing .
Can enter the postman The official website chooses the system to download and install .postman Official website :https://www.postman.com/ 1
Use postman Send it once get request . Use the Academy's official practice address https://httpbin.testing-studio.com/, demonstrate
- Get into postman software interface
- stay URL Fill in https://httpbin.testing-studio.com/get
- choice GET Request mode
- Click on Header,key Value filling accept,value Fill in application/json
- Click on send Button , See what's back

cURL It's a pass URL The transmission of data , Powerful command line tools .cURL It can be done with Chrome Devtool Tools used in conjunction with , Restore the real request sent by the browser , With certification information , Execute without browser , Easy for developers to replay requests 、 Modify parameters, debug , Write a script . It can also be used alone , Adjust the parameters according to your own requirements , Construct a variety of interface test scenarios .
Study curl Before the command , You need to know Chrome Devtool Tools .
Chrome DevTools(Chrome Developer tools ) Is embedded in Chrome A set of tools in the browser for making and debugging web pages . During the test , It is also often used as a simple bag grabbing tool .
How to operate
- Choose the top right corner Chrome menu , Then choose more tools → Developer tools
- Or right click , Select Check / Review element
stay Network In the panel, you can view the details of the resources requested through the network :

- Right click the data on the left , choice Copy → copy as curl, The request content can be converted into curl command .
- Will command copy stay gitbash or bash And run , You will see the return message .
- Refine the above command , Join in -v Parameters can print more details , use 2>&1 Redirect standard error to standard output , Sending this command will get the refined content
The refined command is as follows
curl 'https://home.testing-studio.com/' -H \
'authority: home.testing-studio.com' -H 'pragma: no-cache'\
-H 'cache-control: no-cache' -H 'upgrade-insecure-requests: 1'\
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0)\
AppleWebKit/537.36 (KHTML, like Gecko)\
Chrome/80.0.3987.116 Safari/537.36' \
-H 'sec-fetch-dest: document' \
-H 'accept: text/html,application/xhtml+xml,\
application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,\
application/signed-exchange;v=b3;q=0.9' \
-H 'sec-fetch-site: none' -H 'sec-fetch-mode: navigate' \
-H 'sec-fetch-user: ?1' \
-H 'accept-language: en,zh-CN;q=0.9,zh;q=0.8' \
--compressed -v 2>&1
launch get request
curl"https://httpbin.testing-studio.com/get" -H "accept: application/json"
launch post request
curl -X POST "https://httpbin.testing-studio.com/post" -H "accept: application/json"
proxy Use
curl -x 'http://127.0.0.1:8080'$url
curl Command key parameters

Through a few small combat drills , Learn the usage of some common parameters
- Tamper with request header information , take User-Agent Change it to ”testing-studio“
curl -H "User-Agent:testing-studio""http://www.baidu.com" -v
You can see... In the request User-Agent Success changed to testing-studio
* Trying 14.215.177.39...
* TCP_NODELAY set
* Connected to www.baidu.com (14.215.177.39) port 80 (#0)
> GET / HTTP/1.1
> Host: www.baidu.com
> Accept: */*
> User-Agent:testing-studio
- In the enterprise wechat through curl Command to create a label , This is a post request , adopt –data Parameter passing tagname and tagid
curl
-H "Content-Type: application/json" -X POST \
--data '{"tagname": "hogwarts","tagid": 13}' \
https://qyapi.weixin.qq.com/cgi-bin/tag/create?access_token=$token
- authentication , adopt put Upload to ElasticSearch, Use –user User authentication
curl -X PUT "$ES_HOST/$index/_doc/$id?pretty" \
--user username:password \
-H 'Content-Type: application/json' \
-d "$content"
版权声明
本文为[hogwarts_ beibei]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211352556567.html
边栏推荐
- 终于看清阿里,美团,京东这些企业的真面目了
- Serviceworker cache and HTTP cache
- Decomposing temporary variables in code refactoring
- Workplace etiquette How to use foreign enterprise email
- 牛客网C语言入门刷题记录
- Workplace etiquette How to write email
- Programmer's essential toolbox
- Word input formula shortcut key
- ESP32_ GPIO input, output and interrupt
- Interview with those stereotyped and boring interviewers
猜你喜欢

Comparison of hex, Base64 and URLEncode coding schemes
![[BJDCTF2020]Cookie is so stable(漏洞原理详解)](/img/ef/e05de7a94dc9c2398d714cbf30c4ec.png)
[BJDCTF2020]Cookie is so stable(漏洞原理详解)

Use xamarin to write a beautiful app login and registration interface

Kerberos authentication protocol

72. Edit distance

Text processing - sed

Evolution and construction of data warehouse architecture

OneFlow 如何做静态图的算子对齐任务
![[bjdctf2020] cookie is so stable (detailed explanation of vulnerability principle)](/img/ef/e05de7a94dc9c2398d714cbf30c4ec.png)
[bjdctf2020] cookie is so stable (detailed explanation of vulnerability principle)

Golang dependency injection wire. When executing the wire command, an error is reported: bash: Wire: command not found
随机推荐
Saas.扩展字段 自定义字段
go语言实战-----31-----流媒体架构设计之直播架构、音视频通话(常见 流媒体协议 解释)
jupyter代码无法运行
别人写的叫博客,自己写的叫笔记
OneFlow 如何做静态图的算子对齐任务
牛客网C语言入门刷题记录
苹果表主题图片爬取!
Share price plummeted Robinhood acquired British encryption company for expansion
c语言课程设计——基于链表的考场排位系统
Comparison of hex, Base64 and URLEncode coding schemes
Flutter03-Dart异步
Competition conference of the most fully quantified hardware facilities in the whole network
After four years of outsourcing, it was abandoned
嘉戎技术深交所上市破发:公司市值41亿 应收账款2.8亿
golang依赖注入wire使用 执行wire命令时报错:bash: wire: command not found
The interface needs to be forward compatible. If it is incompatible, open V2 interface
Interpretation of Flink's new features of fine-grained resource management
Writing method of JSS in material UI (notes)
Stackoverflow:IActionContextAccessor Is Null
What does defi need to become mainstream?