2018-10-30接口规范&接口测试

一、http协议/写接口

  • 请求
  1. 请求行:
    请求方法
    uri(协议名://ip:端口号/工程名/资源路径)
    协议版本
  2. 请求头(键值对)
  3. 请求正文自己写:键值对(key=value/多个数据用&连接)。
/guoya-medium/user/signUp.action
userName=yewx&realName=李神龙&password=qwe123&password2=qwe123&checkCode=1234&weixin=65259416&address=中国&phone=13460252399&age=26&education=大专&classType=初级班

sml:<></>(成对显示),通过<></>确定节点位置

image.png
    <customer>
        <customerName>yewx</customerName>
        <cstType>1<cstType>
        <headPortrait></headPortrait>
        <cert></cert>
        <addr></addr>
        <contactinfo>
            <phone>121212121</phone>
            <weichat>89586985</weichat>
            <qq></qq>
            <email></email>
            <spareContact>
                <nsme></name>
                <phone></phone>
            </spareContact>
        </contactinfo>
    </customer>
</request>

json:{}(开始结束),“key”:“value”,多个节点用逗号。

  "html": {
    "body": {
      "parsererror": {
        "-style": "display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black",
        "h3": [
          "This page contains the following errors:",
          "Below is a rendering of the page up to the first error."
        ],
        "div": {
          "-style": "font-family:monospace;font-size:12px",
          "#text": "error on line 1 at column 1: Document is empty
"
        }
      }
    }
  }
}
  • 响应
  1. 响应行:
    协议版本
    响应状态码
    响应状态描述
  2. 响应头
    键值对
  3. 响应正文
    测试要关注的
  4. 常见响应状态码
200 302 400 404 405 500 0000 9999
响应成功 重定向 错误请求 文件不在 服务器不支持 服务器内部错误 响应成功 响应失败

二、接口测试入门

  • 测试范围
  • 测试依据/测试规范
  1. 类型
    离线文档:word文档(不是实时更新),pdf,excel。
    在线文档(swagger):接口规范是根据接口更新的,自动生成请求,有浏览器就能测试。
    没有接口规范,开发必须要提供请求报文模板
  2. word
    通配符
* + 1
0..1可选 0...n可以没有,也可以有多项 1...n至少有1项,也可以有多项 数字1,代表必须且只能填1项

字段的限制

F...x V...x
定长 变长
表示数据是指定x位长的 表示是变长,最长为x位长

接口属性

协议名 请求方法 同步/异步 编码格式 数据格式 资源路径
image.png

请求报文
响应报文

  1. swagger
    请求方法
    资源路径
    求情报文
    响应报文
    字段条件
string integer optional requinre
字串符 数字 可选 必选

数据格式

  1. 接口规范文档

三、接口测试流程

image.png

思维导图:
day12接口规范&接口测试.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容