zoukankan      html  css  js  c++  java
  • 面试官:没搞懂接口测试这些点,哪里来的自信投简历?

    1,目前市面上流行的接口大多有哪几种协议的接口?

    答:http,https,dubbo,rpc等即可。

    2,接口的请求方式有哪几种?

    答:get,post,put,delete,head,Trace,opions等,大多以get和post请求为主

    3、get和post区别是什么?

    答:POST和GET都是向服务器提交数据,并且都会从服务器获取数据。

    区别:

    (1)传送方式:get通过地址栏传输,post通过报文传输,故而post更相对来说私密性一点

    (2)传送长度:get参数有长度限制(受限于url长度),而post无限制

    (3)get请求参数会被完整保留在浏览历史记录里,而post中的参数不会被保留

    (4)get方式大多用作查询接口,获取响应数据;而post方式更多做数据添加、修改或删除等操作

    4,post请求的请求类型有哪几种?

    [if !supportLists]·        [endif] 

    application/json      json字符串

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    application/x-www-from-urlencoded 

      表单传递

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    multipart/form-data 

       主要用于上传文件

    [if !supportLists]·        [endif] 

    5、cookie和session的区别

    [if !supportLists]·        [endif] 

    cookie数据存放在客户的浏览器上,session数据放在服务器上

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    cookie不是很安全,别人可以分析存放在本地的cookie并进行cookie欺骗,考虑到安全应当使用session

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    session会在一定时间内保存在服务器上。当访问增多,会比较占用你服务器的性能,考虑到减轻服务器性能方面应当使用cookie

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    单个cookie保存的数据不能超过4K,很多浏览器都限制一个站点最多保存20个cookie

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    可以将登陆信息等重要信息存放为session;其他信息需要保存,可以放在cookie

    [if !supportLists]·        [endif] 

    6、请求接口中常见的返回状态码

    答:

    [if !supportLists]a.     [endif] 

    1xx -- 信息提示(表示临时的响应。客户端在收到常规响应之前,准备接收一个或多个1xx响应)

    [if !supportLists]b.     [endif] 

    [if !supportLists]c.      [endif] 

    2xx -- 成功(表明服务器成功地接受了客户端请求)

    [if !supportLists]d.     [endif] 

    [if !supportLists]e.     [endif] 

    3xx -- 重定向(客户端浏览器必须采取更多操作来实现请求,例如用户未登录就操作了修改的功能)

    [if !supportLists]f.       [endif] 

    [if !supportLists]g.     [endif] 

    4xx -- 客户端错误(发送错误,客户端有问题)

    [if !supportLists]h.     [endif] 

    [if !supportLists]i.       [endif] 

    5xx -- 服务器错误(服务器由于遇到错误而不能完成该请求)

    [if !supportLists]j.       [endif] 

    常见的有:

    [if !supportLists]·        [endif] 

    200 OK:服务器成功返回用户请求的数据

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    201:用户新建或修改数据成功

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    202:表示一个请求已经进入后台排队(异步任务)

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    301:删除请求数据

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    302:在其他地址发现了请求数据

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    303:建议客户访问其他URL或访问方式

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    304:客户端已经执行了GET,但文件未变化

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    400 :用户发出的请求有错误,服务器没有进行新建或修改数据的操作

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    401:表示用户没有权限(令牌、用户名、密码错误)

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    403 :表示用户得到授权(与401错误相对),但是访问被禁止

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    404:用户发出的请求针对得到是不存在的记录,服务器没有进行操作,该操作是幂等的

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    500:服务器发生错误,用户将无法判断发出的请求是否成功。

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    502:服务器返回超时

    [if !supportLists]·        [endif] 

    7、接口测试用例如何进行设计

    [if !supportLists]·        [endif] 

    针对输入,可按照参数类型进行设计,参数是否必填,参数之间是否存在关联,参数数据类型限制,参数数据类型自身的数据范围值限制;

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    针对接口处理,可按照逻辑进行用例设计;

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    针对输出,可根据结果进行分析设计。

    [if !supportLists]·        [endif] 

    8、如何分析是前端还是后端的问题

    答:

    [if !supportLists]·        [endif] 

    检查接口,前端和后台之间是通过接口文件相互联系的,需要查看接口文件

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    检查请求的数据是什么,反馈的数据又是什么

    [if !supportLists]·        [endif] 

    [if !supportLists]·        [endif] 

    页面可以直接F12,或者抓包查看。如果发送的数据是正确的,但是后台反馈的数据是不符合需求的,那就是后台的问题;如果前端没有请求接口或请求的时候发送数据与需求不符,那这个时候就是前端的问题了。

    [if !supportLists]·        [endif] 

    9、接口测试中,下游接口需要依赖上游接口的数据,该如何处理?

    答:在工具中可以使用全局变量等方式将需要的数据进行传送,或者使用对响应数据进行提取,传给下游接口。

    10、依赖第三方数据的接口如何进行测试?

    答:可以使用fiddler进行调用接口时预设期望响应,mock返回自己设置的响应数据,最大限度的降低对第三方数据接口的依赖

    11、若请求的接口需要先登录后方可请求,如何进行接口测试?

    答:请求登录口获取返回的响应头,或者响应信息中的数据,cookie,token,session等,传递给依赖登录接口的请求头中,发起请求即可。

  • 相关阅读:
    C#跨平台物联网通讯框架ServerSuperIO(SSIO)正式开源... 1
    神秘值分解(Singular Value Decomposition)
    mysql的sql执行计划详解(非常有用)
    springweb flux websocket
    springweb flux 服务器推送事件
    nodejs-express 报错View is not a constructor
    深入理解 Laravel Eloquent(三)——模型间关系(关联)
    Laravel 校验规则之字段值唯一性校验
    Notice: Trying to get property of non-object problem(PHP)解决办法 中间件只能跳转不能返任何数据
    慕客网laravel学习笔记
  • 原文地址:https://www.cnblogs.com/cemaxueyuan/p/13213776.html
Copyright © 2011-2022 走看看