zoukankan      html  css  js  c++  java
  • Postman断言

    断言:用于判断接口请求是否成功!

    最少两个:

    状态断言:200

    业务断言:可以有多个。

     

    //状态断言:

    //断言状态码为200

    pm.test("Status code is 200", function () {

    pm.response.to.have.status(200);

    });

    //业务断言

    //断言返回的结果中包含一个字符串

    pm.test("Body matches string", function () {

    pm.expect(pm.response.text()).to.include("access_token");

    });

    //检查返回的JOSN数据的值。

    pm.test("Your test name", function () {

    var jsonData = pm.response.json();

    pm.expect(jsonData.expires_in).to.eql(7200);

    });

    //断言返回的结果等于一个字符串

    pm.test("Body is correct", function () {

    pm.response.to.have.body("{"errcode":0,"errmsg":"ok"}");

    });

    //断言响应头中是否包含Content-Type

    pm.test("Content-Type is present", function () {

    pm.response.to.have.header("Connection");

    });

    //断言接口的请求时间少于200ms

    pm.test("Response time is less than 200ms", function () {

    pm.expect(pm.response.responseTime).to.be.below(200);

    });

  • 相关阅读:
    人机界面设计
    可用性
    * 产品设计
    界面设计
    原型设计工具——Axure
    原型系统
    交互设计
    原型设计
    Microsoft-PetSop4.0(宠物商店)-数据库设计-Sql
    第1章 游戏之乐——NIM(2)“拈”游戏分析
  • 原文地址:https://www.cnblogs.com/wangfan9/p/13468387.html
Copyright © 2011-2022 走看看