Postman是如何实现接口的自动化测试
3639
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");
- })
本文网址:https://www.zztuku.com/index.php/detail-9820.html
站长图库 - Postman是如何实现接口的自动化测试
申明:如有侵犯,请 联系我们 删除。
您还没有登录,请 登录 后发表评论!
提示:请勿发布广告垃圾评论,否则封号处理!!