站长图库向大家介绍了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");})