当前位置:网站首页>Apifox (postman + swagger + mock + JMeter), an artifact of full stack development and efficiency improvement
Apifox (postman + swagger + mock + JMeter), an artifact of full stack development and efficiency improvement
2022-07-05 00:36:00 【Straw hat Luffy driven by interest】
One 、ApiFox brief introduction
Introduce :ApiFox It's an integrated API file 、API debugging 、API Mock、API An integrated collaboration platform with multiple functions such as automated testing .
Functional orientation :
Apifox = Postman + Swagger + Mock + JMeter
.Download and install : Official website download address
After downloading, install it directly . If you don't want to install the client , It can also be used directly WEB edition , More lightweight .
Two 、ApiFox Usage scenarios of
Apifox Interface management 、 Development 、 Test the whole process integration tool , Use the audience for the entire R & D technology team , The main users are The front-end development
、 The backend development
and Testers
.
- The front-end development
- Interface document management
- Interface data Mock
- Interface debugging
- Front end code is automatically generated
- The backend development
- Interface document management
- Interface debugging
- Interface automation testing
- Back end code is automatically generated
- Testers
- Interface debugging
- Interface automation testing
3、 ... and 、ApiFox With the advantage of one enemy four
In the use of Postman + Swagger + Mock + JMeter when , We often encounter the following problems :
It's very difficult to maintain data consistency between different tools 、 Inefficient . And it's not just about the workload , The bigger problem is data inconsistency between multiple systems , Leading to inefficient collaboration 、 Frequent problems , Developers and testers are in agony .
- Developers in Swagger After defining the document , Interface debugging also needs to go Postman Define it again .
- The front-end development Mock When it comes to data mockjs Define it again , You also need to set it manually Mock The rules .
- Testers need to go to JMeter Define it again .
- Front end according to mockjs Mock The data is developed , Back end according to Swagger The defined interface document is developed , They all passed the test , I thought I could go online right away , As a result, a variety of problems were found :
- The interface changed during development , Only modified Swagger, But they didn't synchronize the changes in time mockjs.
- The interface data type of back-end development is inconsistent with the document , It's hard to see the problem with the naked eye .
- Again , Test in JMeter Well written test cases , When it's really running, you'll find all kinds of inconsistencies .
- Time is long. , The inconsistencies will get more and more serious .
ApiFox How to solve these problems ?
Apifox = Postman + Swagger + Mock + JMeter
Apifox yes API file 、API debugging 、API Mock、API Automated testing integrated collaboration platform .
Through a system 、 A piece of data , Solve the problem of data synchronization between multiple systems . Just define the interface document , Interface debugging 、 data Mock、 Interface testing can be used directly , There is no need to redefine ; Interface documentation and interface development debugging use the same tool , After the interface debugging is completed, it can ensure that it is completely consistent with the interface document definition . Efficient 、 In time 、 accuracy !
Four 、ApiFox Simple introduction
Install the client ( Or use WEB End ) after , You can use it directly :
- Create new teams and projects :
- Set the theme :( Default is white theme )
- The interface test : Get weather data
The corresponding results after running are as follows :
{
"reason": " The query is successful !",
"result": {
"city": " Hangzhou ",
"realtime": {
"temperature": "14",
"humidity": "55",
"info": " Fine ",
"wid": "00",
"direct": " dongfeng ",
"power": "3 level ",
"aqi": "140"
},
"future": [
{
"date": "2022-02-27",
"temperature": "8/14℃",
"weather": " Sunny to cloudy ",
"wid": {
"day": "00",
"night": "01"
},
"direct": " The east wind turns and there is no wind direction "
},
{
"date": "2022-02-28",
"temperature": "9/20℃",
"weather": " Cloudy to drizzle ",
"wid": {
"day": "01",
"night": "07"
},
"direct": " Continue to turn from no wind to northwest wind "
},
{
"date": "2022-03-01",
"temperature": "7/15℃",
"weather": " Light rain ",
"wid": {
"day": "07",
"night": "07"
},
"direct": " The northwest wind turns and there is no wind direction "
},
{
"date": "2022-03-02",
"temperature": "7/17℃",
"weather": " It's sunny to cloudy ",
"wid": {
"day": "00",
"night": "02"
},
"direct": " There is no wind direction "
},
{
"date": "2022-03-03",
"temperature": "8/14℃",
"weather": " Light to moderate rain ",
"wid": {
"day": "07",
"night": "21"
},
"direct": " There is no wind direction "
}
]
},
"error_code": 0
}
5、 ... and 、API Interface design and interface documents
Apifox Interface documentation follows OpenApi 3.0 ( primary Swagger)、JSON Schema At the same time , It's very easy to use visualization
Document management function , Zero learning cost , Very efficient . And support online sharing of interface documents .
When we define API After the interface , It can be directly generated online API file :
6、 ... and 、API data Mock
Interface data Mock: built-in Mock.js Rules engine , Very convenient mock All kinds of data , And you can define the data structure and write mock The rules . Support adding “ expect ”, According to the request parameters, different mock data . most important of all Apifox Zero configuration
that will do Mock Very human data , The details are introduced later in this paper .
- Create a new Mock Interface :
- Define the interface name and input parameters :
- Set up mock The corresponding result :
We can click the preview to view the generated random mock data (ApiFox The most intelligent place is , He can set it according to you mock Parameters , To automatically identify and randomly select the corresponding parameter values , For example, our birthday The field will be automatically recognized as birthday ):
- Code auto generation :
We can customize mock Data interface , To automatically generate the corresponding entity class code .
- preservation mock Interface , And run the test :
Test browser access :
7、 ... and 、API automated testing
Provide interface set testing , You can choose the interface ( Or interface use cases ) Quickly create test sets . At present, more functions of interface automation test are still under development , Coming soon ! The goal is : JMeter Some functions are basically , And use it better .
- Reference resources :ApiFox Official documentation of automated testing
8、 ... and 、 Database integration
As shown in the figure below ,ApiFox You can connect to remote or local databases , It can be used as a lightweight visualization tool for database operation :
make new connection :
Support multiple source data import :
Nine 、 Online debugging
This document is written in Apifox It's done , I have tried this tool before , I didn't expect that so many powerful new functions have come out recently .
Click the run button in the upper right corner of the document , Will appear “ The online operation ” Module :
You can directly debug the interface on this interface ! direct 1. Fill in the parameters ,2. Select environment ,3. Point send , The interface request is sent out ! Here is the return result ! There is no need for Postman! Not to mention API Copy it again !
I thought. , If before the launch , It's using Apifox Words , There is simply no accident :
Parameter does not exist ? I got the data after online debugging , By comparison, I know which parameter does not exist
Wrong parameter type ? alike , After online commissioning , By comparison , I know which parameter has the wrong type
Interface does not exist ( Because the interface is written incorrectly )? When debugging, it will be reported that the interface does not exist , Find the back end at the first time ~
Ten 、ApiHub
ApiHub It integrates many third-party applications Api Tools , for example :
Let's take a gaud map API Use case of :
- Use the Gaud map API Call the weather interface : Reference documents
The effect is as follows :
Of course, you can also test other interface calling functions of Gaode map here ~
other
Besides ApiFox It also has many other functions , for example :
- Data model : Reusable data structure , Defining interfaces
Return data structure
AndRequest parameter data structure
( only JSON and XML Pattern ) You can directly reference . Support model direct nested reference , direct JSON/XML Smart import , Support oneOf、allOf And other advanced combination modes . - Interface debugging :Postman Some functions , For example, environment variables 、 In front of / Post script 、Cookie/Session Global Shared And so on ,Apifox There are , And ratio Postman More efficient and easy to use . After the interface runs, click
Save as use case
Button , It can generateInterface use cases
, Interface use cases can be run directly later , No more parameters need to be entered , Very convenient . Custom script 100% compatible Postman grammar , And support running javascript、java、python、php、js、BeanShell、go、shell、ruby、lua And other language codes . - Interface use cases : Usually, an interface has multiple use cases , such as
The parameters are correct
Use cases 、Parameter error
Use cases 、Data is empty
Use cases 、Different data states
Use cases, etc . The correctness of data will be automatically verified when running the interface case , Using interface use cases to debug interfaces is very efficient . - Database operation : Support reading database data , Used as an interface request parameter . Support reading database data , Used to verify ( Assertion ) Whether the interface request is successful .
- Quick request : similar Postman Interface debugging mode , It is mainly used for temporary debugging
No documentation required
The interface of , You can quickly debug without defining the interface in advance . - Code generation : Define according to the interface and data model , Automatic system generation
Interface request code
、Front end business code
AndBack end business code
. - Teamwork :Apifox Born for teamwork , Interface cloud real-time synchronous update , ripe
The team / project / Member rights
management , Meet the needs of various enterprises . - …
Want to know more , You can check the official website :ApiFox Official website address ,ApiFox Official Q & A qun
边栏推荐
- const、volatile和restrict的作用和用法总结
- Every time I look at the interface documents of my colleagues, I get confused and have a lot of problems...
- Identifiers and keywords
- 华为200万年薪聘请数据治理专家!背后的千亿市场值得关注
- uniapp上传头像
- [IELTS reading] Wang Xiwei reads P4 (matching2 paragraph information matching question [difficult])
- 他做国外LEAD,用了一年时间,把所有房贷都还清了
- MongoDB系列之学习笔记教程汇总
- The company needs to be monitored. How do ZABBIX and Prometheus choose? That's the right choice!
- A new method for analyzing the trend chart of London Silver
猜你喜欢
基本放大电路的学习
lambda expressions
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation
Specification for fs4061a boost 8.4v charging IC chip and fs4061b boost 12.6V charging IC chip datasheet
程序员SQL数据脚本编码能力弱,BI做不出来怎么办?
华为百万聘请数据治理专家!背后的千亿市场值得关注
Safety learning week4
2022.07.03(LC_6108_解密消息)
巩固表达式C# 案例简单变量运算
The waterfall flow layout demo2 (method 2) used by the uniapp wechat applet (copy and paste can be used without other processing)
随机推荐
[circuit design] optocoupler use and circuit design summary
Is it safe to open and register new bonds? Is there any risk? Is it reliable?
Hologres query management and timeout processing
Detailed explanation of openharmony resource management
leetcode494,474
He worked as a foreign lead and paid off all the housing loans in a year
Ruby tutorial
[selenium automation] common notes
【雅思阅读】王希伟阅读P4(matching2段落信息配对题【困难】)
The company needs to be monitored. How do ZABBIX and Prometheus choose? That's the right choice!
Visual explanation of Newton iteration method
Five papers recommended for the new development of convolutional neural network in deep learning
Oracle case: SMON rollback exception causes instance crash
TS quick start - functions
MySQL uses the explain tool to view the execution plan
雅思考试流程、需要具体注意些什么、怎么复习?
Microservice
分布式BASE理论
[Yocto RM]11 - Features
P4281 [ahoi2008] emergency assembly / gathering (LCA)