zoukankan      html  css  js  c++  java
  • 2,postman的tests的断言写法

    tests的断言主要是分为三类

    状态码,header内容和波body内容的测试,波body的不常用( 不容易控制)

    pm.expect(pm.response).to.have.status("value")

    pm.expect(pm.response).to.have.header("value")

    pm.expect(pm.response).to.have.body("value")

    测试包含字符串或者是等于字符串

    pm.expect(pm.response.json()["element"][element2]).to.eql("value")//使用json的时候可以使用键值对值

    或者使用pm.expect(pm.response.json().element.element2).to.eql("value")

    pm.expect(pm.response.text()).to.include("value")//当使用text的时候不能使用字典形式找到对应键值

    相应时间和状态码的测试

    pm.expect(pm.response.responseTime]).to.be.below("value")

    pm.expect(pm.response.code).to.be.oneOf("value")

  • 相关阅读:
    CCCC练习即感
    1003 我能通过
    录制开讲啦杂感
    OOP第三次上机
    关于C++随机函数
    蓝桥杯杂感。
    CF502C The Phone Number
    It's a secret
    2017-06-22
    2017-05-12
  • 原文地址:https://www.cnblogs.com/wuzhenhu/p/8758486.html
Copyright © 2011-2022 走看看