Postman测试接口

来源:互联网 发布:手机网络运营商无服务 编辑:程序博客网 时间:2024/06/14 00:57

引言

    这一周最大的收获就是,接手新项目,整理业务需求,并做API接口测试。最开始项目中用到的是Postman。接下来介绍postman的简单实用。Postman: The Complete API Development Environment。

方法

(1) 查询返回的内容是单个实体的以find开头 比如:T findById(String id);(2) 查询返回的内容是实体集合 以select或query开头selectByExample(@Param("example")TExample example)queryByExample(@Param("example")TExample example)(3)查询返回内容非以上内容 以get开头 
比如:查询返回的数量等 getCountByExample(@Param("example")TExample example)

改(put)

1、编辑角色信息 PUT 实体

代码:

@RequestMapping(value = {"/updateTeacher"}, method = RequestMethod.PUT)@CrossOrigin@ResponseBodypublic ItooResult updateTeacher(HttpServletRequest request, HttpServletResponse response, @RequestBody StaffModel staffModel) {}



效果:



 
Postman测试步骤:
 


2、PUT 单个

代码:

@CrossOrigin@RequestMapping(value = "/updatePaymentRecordIspayById/{Id}", method = RequestMethod.PUT)@ResponseBodypublic ItooResult updatePaymentRecordIspayById(@PathVariable String Id){}


效果:



 Postman测试步骤:


 


查(get)

1、GET / find 

代码:

@RequestMapping(value = {"/findTeacherById"}, method = RequestMethod.GET)@CrossOrigin@ResponseBodypublic ItooResult findById(HttpServletRequest request, HttpServletResponse response, String StaffId) {    }

效果:

Postman测试步骤:



2、query

代码:


@RequestMapping(value = {"/queryTeacherPage"}, method = RequestMethod.GET)@CrossOrigin@ResponseBodypublic ItooResult queryTeacherPageLike(HttpServletRequest request, HttpServletResponse response, String strLike,int pageNum, int pageSize) {}


效果:


Postman测试步骤:

增(post)

add

代码:

@RequestMapping(value = {"/addTeacher"}, method = RequestMethod.POST)@CrossOrigin@ResponseBodypublic ItooResult addTeacher(HttpServletRequest request, HttpServletResponse response, @RequestBody StaffModel staffModel) {}


效果:



Postman测试步骤:


删(delete)

1、删除 单个参数

代码:

@CrossOrigin@RequestMapping(value="/deleteLearningExperienceById/{Id}",method = RequestMethod.DELETE)@ResponseBodypublic ItooResult deleteLearningExperienceById( @PathVariable String Id)  {}


效果:

Postman测试步骤:



2、删除 List集合

代码:
@RequestMapping(value = {"/deleteTeacher"}, method = RequestMethod.DELETE)@CrossOrigin@ResponseBodypublic ItooResult deleteTeacher(HttpServletRequest request, HttpServletResponse response, @RequestBody List<String> ids) {}


效果:

Postman测试步骤:


总结

   前后端的接口规范,主要在于接口的参数书写是否正确,先实践找到正确的方法然后再深入理解。
原创粉丝点击