postman-检查点

2025-10-26 05:36:42

1、postman发送get请求

01输入url(统一资源定位器(Uniform Resource Locator)

02点击send

入下图所示:

postman-检查点

2、这里我们设置检查点的信息包含:“网易公益_有态度的公益门户”

同时响应信息包含httpCode为200,欠胳响应成功。

01点击url下方的test

如图所示:

postman-检查点

3、可以直接手动输入JS函数,也可以在右侧方框里选择tests,

在learn more about tests 可物包以查看学习更多的函数。肤速激

如图所示:

postman-检查点

1、找到Response body:Contains string

点击。

tests中便出现函数:

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

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

});

将"string_you_want_to_search" 替换为 我们需要的检查内容:“网易公益_有态度的公益门户”

如下图所示:

postman-检查点

postman-检查点

2、同样我们找到Status code:code is 200,

点击。生成函数如下:

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

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

});

postman-检查点

3、点击save,然后点击send,发送请求。

然后查看 test results

如下图所示:

因此,我们针对我们的API设置了2个测试检查点,

01)status code等于200

02)response body中包含字符串:网易公益_有态度的公益门户

版权声明:本文为博主原创文章,转载请注明出处,谢谢

postman-检查点

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢