当前位置:网站首页>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
边栏推荐
- Relationship between classes and objects
- Multilingual Wikipedia website source code development part II
- Design of emergency lighting evacuation indication system for urban rail transit station
- What did I pay for it transfer to testing post from confusion to firmness?
- npm install报错 强制安装
- 4. Scala writes HelloWorld in idea, in-depth analysis of accompanying objects, and association of source packages
- It's too convenient. You can complete the code release and approval by nailing it!
- 人生无常,大肠包小肠, 这次真的可以回家看媳妇去了。。。
- Basic concept and usage of redis
- Kibana index, mapping, document operation
猜你喜欢
A new method for analyzing the trend chart of London Silver
Power operation and maintenance cloud platform: open the new mode of "unattended and few people on duty" of power system
[IELTS reading] Wang Xiwei reading P4 (matching1)
《论文笔记》Multi-UAV Collaborative Monocular SLAM
Design of emergency lighting evacuation indication system for urban rail transit station
How many triangles are there in the golden K-line diagram?
Verilog tutorial (11) initial block in Verilog
js如何实现数组转树
[selenium automation] common notes
The company needs to be monitored. How do ZABBIX and Prometheus choose? That's the right choice!
随机推荐
[Yocto RM]10 - Images
PyTorch: In-place Operation
Power operation and maintenance cloud platform: open the new mode of "unattended and few people on duty" of power system
uniapp微信小程序拿来即用的瀑布流布局demo2(方法二)(复制粘贴即可使用,无需做其他处理)
程序员SQL数据脚本编码能力弱,BI做不出来怎么办?
Basic points of the game setup of the points mall
Paper notes multi UAV collaborative monolithic slam
初识ROS
Summer challenge brings you to play harmoniyos multi terminal piano performance
Hill sort of sorting
[IELTS reading] Wang Xiwei reading P4 (matching1)
实战模拟│JWT 登录认证
If you open an account of Huatai Securities by stock speculation, is it safe to open an account online?
Fs8b711s14 electric wine bottle opener MCU IC scheme development special integrated IC
lambda expressions
How to effectively monitor the DC column head cabinet
Skills in analyzing the trend chart of London Silver
Significance of acrel EMS integrated energy efficiency platform in campus construction
[paper reading] Tun det: a novel network for meridian ultra sound nodule detection
Is it safe to open and register new bonds? Is there any risk? Is it reliable?