当前位置:网站首页>[Learning Records of Boxue Valley] Super summary, share with heart | Software Testing Interface Testing Basics

[Learning Records of Boxue Valley] Super summary, share with heart | Software Testing Interface Testing Basics

2022-08-02 03:34:00 Nauica

接口测试基础

1. 接口测试理论

  • 接口:
    • 分裂
      • 硬件接口
      • 软件接口(主体)
    • 概念:数据交互的通道
  • 接口类型:
    • 系统之间的接口
    • 系统内部的接口
  • 接口测试:
    • 针对接口进行测试,Is primarily to test the data transfer、交互、Control management process as well as the interface between reliance on
    • 原理:
      • Simulate the client connection is established
      • 发送请求
      • 服务端处理请求并响应
      • 校验响应数据
    • 特点:
      • 测试可以提前介入,修改bug成本低,符合质量前移的理念
      • Can be found in the page doesn't spot the problem
      • 低成本、高收益
      • 接口测试不同于单元测试,Is standing in the user's perspective on the overall business test
    • 实现方式:
      • 通过工具实现:
        • Postman
        • Jmeter
      • 通过代码实现:
        • Python + Requests
    • 接口自动化测试概念:
      • 针对接口进行测试,Use tools or code instead of people to test

2. HTML 协议

  • 介绍:超文本传输协议,A kind of widely used on the Internet way
  • 特点:http://www.itcast.cn:8080/news/index.html?uid=123&page=1
    • Based on the client and server mode
    • 简单快捷
    • 灵活
    • 无状态
    • 无连接
  • url 格式解析
    • 说明:统一资源定位符
    • 格式:协议、域名、端口号、资源路径、参数
      • 示例:
      • 协议:HTTP、HTTPS、FTP等
      • 域名:可以是域名也可以是IP地址
      • 端口号:默认的端口号可以省略
        • http:80
        • https:443
      • 资源路径:
        • 图片、视频、音频、链接、接口等
      • 参数:
        • ?:隔离uil主体与参数部分内容
        • & :存在多个参数时,使用&进行链接
  • HTTP请求
    • 组成:请求行、请求头、请求体
      • 请求行:
        • 位置:第一行信息
        • 内容:
          • 请求方式
          • 资源路径
          • 协议与版本
      • 请求头:
        • 位置:第一行之后,空行之前的内容
        • 内容:
          • 主要以键值对形式存在
          • Content-Type = application/json
      • 请求体:
        • 前提:get没有请求体,一般请求体在post与put方式中使用
        • 位置:空行之后
        • 内容形式:json、html、text等
      • 请求方式:
        • get:查询数据
        • post:新增数据
        • put:修改数据
        • delete:删除数据
  • HTTP响应
    • 组成:状态行、响应头、响应体
      • 状态行:
        • 位置:第一行信息
        • 内容:
          • 状态码:
            • 2xx:请求成功
            • 3xx:重定向
            • 4xx:客户端存在问题
            • 5xx:The service side there is a problem
      • 响应头:
        • 位置:第一行之后,空行之前
        • 内容:键值对形式存在,Used to describe the server information
      • 响应体:
        • 位置:空行之后
        • 响应数据:xml、json、html 等

3. 接口规范

1. 传统接口风格

  • 不同的公司、不同的项目、Different development between the interfaces of the difference is very big

  • Request way generally use only get 和 post

  • The response status code USES only200表示处理成功

2. RESTful结构风格(规范)

  • 规范风格:是规范,Is not a standard or rules
  • 示例:
    • URL : 协议://域名:端口号/资源路径/{资源集合}/{指定资源}
    • 请求方法:get post put delete
    • 状态码:200 201 204
  • Request method with a status code corresponding( 重点 )
    • 查询操作:请求方法【get】响应状态码【200】
    • 新增操作:请求方法【post】响应状态码【201】
    • 修改操作:请求方法【put】响应状态码【201】
    • 删除操作:请求方法【delete】响应状态码【204】

4. 测试流程

  1. 需求分析
  2. API文档(接口文档)解析
  3. 设计测试用例
  4. 执行测试用例
    • 使用工具
    • 使用代码
  5. 缺陷跟踪与管理
  6. 生成测试报告
  7. Sustainable inheritance

5. API 文档

  • 定义:

    • API 文档:Is a description interface information(请求:请求方式、请求地址、请求参数;响应:状态码、响应数据)的文档
  • 功能:

    • 便于前端开发和后端开发更好的协作
    • When project alternation and change,Easy-to-use and maintenance
    • 便于测试尽早介入
  • 内容:

    • 基本信息:接口名称、请求方式、接口地址(path)、接口描述
    • 请求参数:
      • 请求头(headers):
      • 请求体(body):
        • 前提:post与put有请求体
        • 内容:参数名称、参数类型、是否必填、示例、备注等
    • 响应数据:
      • 状态码
      • 响应数据:参数名称、参数类型、是否必填、示例、备注等
原网站

版权声明
本文为[Nauica]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/214/202208020320137333.html