当前位置:网站首页>【学习】接口测试用例编写和测试关注点
【学习】接口测试用例编写和测试关注点
2020-11-06 21:30:00 【青青QQ】
一、为什么要做接口测试
在日常开发过程中,有人做前端开发,有人负责后端开发。接口就是连接前后台,由于前端开发和后端开发的速度可能不一样,例如后端开发好了,但是前端没有开发。那么我们是不是就不需要测试呢?一般我们大部分人都是做功能测试,很多是界面的功能测试。如果你理解了接口测试,那么你就可以针对接口进行测试。
二、什么是接口、什么是接口测试
接口:主要是子模块或者子系统间交互并相互作用的部分。
这里说的接口是广义的,客户端与后台服务间的协议;插件间通信的接口;模块间的接口;再小到一个类提供的方法;都可以理解为接口。
接口测试:是指针对模块或系统间接口进行的测试。
三、接口测试流程
需求讨论,需求评审,场景设计,编写用列,准备数据,执行测试
四、接口测试用例设计
1接口测试的用例设计,主要从输入和接口处理两方面考虑:
1)针对输入,可按照参数类型进行设计;
2)针对接口处理,可按照逻辑进行用例设计;
3)针对输出,可根据结果进行分析设计。
2针对输入设计
对于接口来说,输入就是入参。常见参数类型有:
(1)数值型(int,long,float,double等)
(2)字符串类型
(3)数组或链表
(4)结构体
五.怎么进行接口测试
通过工具模拟客户端向服务端发送请求并接受服务器返回的数据来对接口的功能,逻辑业务,异常,安全进行测试
功能测试:测试这个接口的功能是否实现,并且测试这个接口是否按照接口文档来进行开发的(比如说接口文档规定了一些关键字,而开大的时候把关键字改成了其他的关键字,因为在整个项目周期,并不只有一个开发而是有多个,所以可能因为在开发过程中因为关键字不一样导致某些开发的功能异常,还有自动化脚本也会发生异常)
逻辑业务,主要指的是一些逻辑业务依赖关系(比如支付宝提交订单的时候要保证你是在登录的情况下,如果你没有登录而提交成功了,这就是异常,可以修改请求的cookie来测试)
异常测试:参数异常:关键字参数(应用其他的关键字替换进行测试)、参数为空、参数多少(通过添加参数增添个数),参数错误。数据异常:关键字数据(填入的数据用其他的数据语言的数据替用)、数据长度、数据为空、数据错误。
由于我们项目前后端调用主要是基于http协议的接口,所以测试接口时主要是通过工具或代码模拟http请求的发送与接收。工具有很多如:apipost、jmeter、java+httpclient、robotframework+httplibrary等。
–也可以用 接口自动化来实现,就是用代码实现,框架和UI自动化差不多,发送请求用断言来判断。
六、接口测试需要用到的工具
接口测试常用的工具,fiddler抓取请求,apipost模拟客户端通过对fiddler抓取的请求修改并发送到服务端并接收服务器返回的数据及异常来进行验证接口。工具不是固定的,需要根据项目来进行选择。
七、接口测试发现的典型问题
接口测试经常遇到的bug和问题,如下:
(1)传入参数处理不当,导致程序crash;
(2)类型溢出,导致数据读出和写入不一致;
(3)因对象权限未进行校验,可以访问其他用户敏感信息;
(4)状态处理不当,导致逻辑出现错乱;
(5)逻辑校验不完善,可利用漏洞获取非正当利益等。
工具下载链接:
版权声明
本文为[青青QQ]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4599769/blog/4704921
边栏推荐
- Construction of encoder decoder model with keras LSTM
- Analysis of partial source codes of qthread
- It's easy to operate. ThreadLocal can also be used as a cache
- 消息队列(MessageQueue)-分析
- What are the common problems of DTU connection
- StickEngine-架构11-消息队列(MessageQueue)
- Introduction to X Window System
- 一篇文章教会你使用Python网络爬虫下载酷狗音乐
- Lane change detection
- Who says cat can't do link tracking? Stand up for me
猜你喜欢
一路踩坑,被迫聊聊 C# 代码调试技巧和远程调试
What are PLC Analog input and digital input
Staying up late summarizes the key points of report automation, data visualization and mining, which is different from what you think
Introduction to the structure of PDF417 bar code system
一篇文章教会你使用Python网络爬虫下载酷狗音乐
Free patent download tutorial (HowNet, Espacenet)
前端未來趨勢之原生API:Web Components
有了这个神器,快速告别垃圾短信邮件
Outsourcing is really difficult. As an outsourcer, I can't help sighing.
Get twice the result with half the effort: automation without cabinet
随机推荐
Wow, elasticsearch multi field weight sorting can play like this
【转发】查看lua中userdata的方法
Isn't data product just a report? absolutely wrong! There are university questions in this category
What are the criteria for selecting a cluster server?
Using NLP and ml to extract and construct web data
The difference between gbdt and XGB, and the mathematical derivation of gradient descent method and Newton method
Details of dapr implementing distributed stateful service
Advanced Vue component pattern (3)
一部完整的游戏,需要制作哪些音乐?
TensorFlow中的Tensor是什么?
一篇文章教会你使用Python网络爬虫下载酷狗音乐
Mac installation hanlp, and win installation and use
WeihanLi.Npoi 1.11.0/1.12.0 Release Notes
python100例項
Who says cat can't do link tracking? Stand up for me
What are Devops
Analysis of query intention recognition
Outsourcing is really difficult. As an outsourcer, I can't help sighing.
【字节跳动 秋招岗位开放啦】Ohayoo!放学别走,我想约你做游戏!!!
How to hide part of barcode text in barcode generation software