当前位置:网站首页>Detailed explanation of apifox

Detailed explanation of apifox

2022-09-23 08:44:13anne

一、认识 Apifox

  1. 为什么要使用 Apifox 工具
    Against the background of current industry development,Most projects are based on 前后端分离 The architecture,from front to back、测试、Joint development by different teams such as operation and maintenance,Between the team can be very good 协同合作 Undoubtedly, it directly determines the final effect of the project.Collaboration is actually a pain point for most development teams.,为了便于团队协作,There are also some R&D management tools such as Jira、Teambition,应用也比较广泛,They primarily focus their functionality on project management、代码托管、Defect tracking, etc..

But in the actual development process,Collaboration between teams is ineffective,For example, after the requirements review is completed,Front-end and back-end interface definition and send an engineer to define API 文档(一般使用 Swagger);Then enter the development process,后端按照 API Documentation development interface,When debugging, you need to follow the documentation at Postman 中重新定义一遍;Before the backend develops the interface,If the front end needs to be developed, it must follow the API documentation on its own Mock 数据,也就是在 Mock.js Rewrite the interface definition and Mock 规则;Before the interface development is completed, the test needs to follow the documentation to JMeter 中写测试用例,It is inevitable to write the interface definition again;
在这里插入图片描述

It can be seen that the entire development process revolves around API 开展的,In this process, different teams need to operate on the definition of the interface,This will lead to many problems such as inconsistent definitions during joint debugging..and using different tools such as Swagger、Postman、Mock、JMeter,Obviously caused a lot of waste and inefficient use of resources.

而 Apifox was born to solve the above problems,Apifox The purpose of research and development—— 节省研发团队的每一分钟.

2. Apifox 有哪些功能

针对以上问题,Apifox Do practical solutions are put forward,在 Apifox The official website shows such a sentence Apifox = Postman + Swagger + Mock + JMeter,And the four development tool is the core functions of integrated together,使得前端、后端、Tests can be easily defined and used API,Avoid repetitive work,The most important is about API Any adjustments made can be synced to each team in real-time,Ensure consistency in all aspects of the project process.
在这里插入图片描述

除此之外,Apifox It also has the following rich functions:

API 文档:Visual interface document management,Support data structure definition,Multiple interfaces reuse the same data structure,接口文档遵循 OpenAPI 规范,Support the online sharing of interface documents.
API 调试:拥有 Postman 的所有功能,更好用,Can automatic calibration data structure,Automatically discover interface exceptions.
API 自动化测试:Perfect interface scene test function,Support calls to other programming languages.
API 数据 Mock:零配置即可 Mock 出非常人性化的数据,内置 mock.js 规则引擎,Support for custom expectations.
CI 持续集成:Support command line mode to run interface test,支持集成 Jenkins 等持续集成工具.
数据库操作:Support database reading and interface verification.
自动生成代码.
数据导入/导出:支持导入/Export to more than ten data formats.
团队协作.

For more detailed functions, see Apifox 官网 www.apifox.cn.

3. API First The development process under the concept

Apifox 秉承的是 API first(API 优先)的先进理念,That is, the development team first API,然后围绕 API Expand Design and Development.使用 Apifox 之后,The development efficiency will be greatly improved and the working experience of all parties will be better,Collaboration with external teams will also be smoother.The development process under this concept is as follows:

开发阶段 工作任务
设计阶段 Determine the interface design idea according to the requirements document,The interface designer designs the first draft of the interface,Then review the interface together with the front and back ends,完善接口文档.
开发阶段 前端:Apifox 会根据接口文档自动生成 Mock 数据,Go directly into the development process without handwriting Mock 规则.
后端:使用 Apifox Define the debug interface according to the interface,Even if the interface changes during development,When debugging, modify the interface definition to automatically update the document.
测试:Generate test cases using interface cases saved during backend debugging.
联调和测试阶段 At this point all interface development is completed,测试/The backend uses the collection test function for multi-excuse integration testing.

二、上手操作 Apifox

1. 安装 Apifox

直接官网下载 Apifox 即可,可以支持 Windows、mac、Linux 三个平台,You can also use the web version directly;
在这里插入图片描述

After the download is complete, click“下一步”即可安装,To start the software for the first time, you need to register and log in.

在这里插入图片描述

初始界面如下:

在这里插入图片描述

2. 团队管理&项目管理

点击 “新建团队” 进行创建;

在这里插入图片描述

创建成功如下,Can a new project in the team、Operations such as adding members and granting permissions;
在这里插入图片描述

接下来新建一个项目;

在这里插入图片描述

Click on the item to enter as follows,available for this project、接口管理、自动化测试、Related operations such as project settings and inviting members;

在这里插入图片描述

3. 编写接口文档

点击“+” --> “新建接口”;
在这里插入图片描述

The following is an example of a new login interface I created:

接口地址、接口基本信息

在这里插入图片描述

请求参数设置
在这里插入图片描述

Interface response settings
在这里插入图片描述

After setting the relevant properties,点击保存,At this point, a Apifox 的接口文档,You can see that you can also run this interface or directly generate code operations;
在这里插入图片描述

4. 智能 Mock 数据

You can see that in the documentation there is a Mock 区域,包含 Mock url;

在这里插入图片描述

we copy this mock 地址,在浏览器打开,can directly access to mock 数据;
在这里插入图片描述

在 API After the document is set, you can use this directly Mock Address for development.

5. 在线分享 API 文档

点击“项目概览”,New online share;

在这里插入图片描述

Set parameters such as sharing objects;

在这里插入图片描述

Then you can copy the link to share;
在这里插入图片描述

View the link effect as follows;
在这里插入图片描述

6. 自动化测试

在进行自动化测试之前,We first save the current interface document as a use case,It is convenient to directly import interface use cases into automated tests later.
在这里插入图片描述

点击“自动化测试” --> “测试用例” --> “创建” 新建测试用例;
在这里插入图片描述

After the creation is successful, click on the use case to enter,如下;

在这里插入图片描述

点击 “添加步骤”,然后选择 “从【Interface use case import】”;

在这里插入图片描述

After importing the use case is as follows;
在这里插入图片描述

At this point, you can set relevant running properties including the running environment、线程数等,also test data,Import is supported here CSV Or manually add the dataset.

在这里插入图片描述

最后点击 “运行” 进行测试;

在这里插入图片描述

  1. API Hub
    Apifox Provides us with the most commonly used API,It can be easily used directly and debugged with one click.

点击 “切换项目”,然后选择 API Hub,如下;
在这里插入图片描述

点击进入一个 API,We can choose the interface to debug and run;
在这里插入图片描述

三、Apifox 电梯直达

Apifox 作为一款 完全免费 的国产软件,注册登录即可使用.How is it, only you guys will know when you start using it?.For software download and learning, please go to Apifox 官方网站:www.apifox.cn.

原网站

版权声明
本文为[anne]所创,转载请带上原文链接,感谢
https://chowdera.com/2022/266/202209230827107298.html

随机推荐