Postman是如何实现接口的自动化测试

分类:建站教程 时间:2024-12-22 18:56 浏览:0 评论:0
0

Postman是如何实现接口的自动化测试,使用 postman 来实现项目的接口自动化测试。


Postman是如何实现接口的自动化测试


接口开发之后使用 postman 工具来做基础测试,利用 postman 提供的一些功能,能过实现接口的自动化测试。

下面记录一些常用的基本测试方法,方便后续查找。

postman测试使用说明

postman 支持 Pre-request script 以及 Tests,脚本均使用 javascript 编写,使用和正常的前端 js 没有任何差别, postman 提供了一个封装的库 pm 简化了一些操作。


测试用例

接口正常响应

pm.test("200 test",function(){
  pm.response.to.have.status(200);
})

接口功能正常

pm.test("api function ok",function(){
  var res=JSON.parse(pm.response.text())
  var code=res.code;
  var message=res.message;
  pm.expect(code).equal(0);
  pm.expect(message).equal("success");
})


1. 本站所有资源来源于用户上传或网络,仅作为参考研究使用,如有侵权请邮件联系站长!
2. 本站积分货币获取途径以及用途的解读,想在本站混的好,请务必认真阅读!
3. 本站强烈打击盗版/破解等有损他人权益和违法作为,请各位会员支持正版!
4. 建站教程 > Postman是如何实现接口的自动化测试

用户评论

function fuckyou() { window.close(); window.location = "about:blank"; } function ck() { console.profile(); console.profileEnd(); if (console.clear) { console.clear() }; if (typeof console.profiles == "object") { return console.profiles.length > 0; } } function hehe() { if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) || ( typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) { fuckyou(); } if (typeof console.profiles == "object" && console.profiles.length > 0) { fuckyou(); } } hehe(); window.onresize = function() { if ((window.outerHeight - window.innerHeight) > 200) fuckyou(); }