接口测试中三种传参请求(Map、request、Integer)解析
注册企业接口传入的是一个request,查询企业接口传入的是一个integer;根据名称和国家名称模糊匹配接口传入的是一个Map;
针对三种不同的传参我怎么作接口测试呢?
1 package com.web.crm.services; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; @Service
public class test {
@Autowired
private ICustomerInterface CustomerInterface;
@Autowired
private IShippingPortcodeInterface ShippingPortcodeInterface; //test
@SuppressWarnings({ "rawtypes" })
public List<TestResult> test(){
//返回结果
List<TestResult> result = new ArrayList<TestResult>();
/**
* 功能描述:注册企业
* CustomerResponse registerCustomer(CustomerRequest<?> request)
* 接口请求带request 案例
*/
//实例化一个请求
CustomerRequest request = new CustomerRequest();
//实例化一个参数
CusCustomerEntity customerEntity = new CusCustomerEntity();
customerEntity.setCusName("微软");
//将参数写人请求
request.setEntity(customerEntity);
//实例化一个参数
CusEmployeeEntity CusEmployeeEntity = new CusEmployeeEntity();
CusEmployeeEntity.setEmpTypeId(123);
CusEmployeeEntity.setCompanyEmail("yiy11@12.com");
CusEmployeeEntity.setMobilePhone("13400065433");
//将参数写人请求
request.setEmployeeEntity(CusEmployeeEntity);
//实例化一个响应
CustomerResponse response = new CustomerResponse();
//将请求传入被测接口方法
response=CustomerInterface.registerCustomer(request);
//逻辑判断getResultCode是否10000
if (StringUtils.equals(response.getResultCode(), ReturnResult.SUCCESS.getResultCode())) {
result.add(new TestResult(AlertMessageLevel.SUCCESS, "注册企业", response.getResultCode(), response
.getResultMessage()));
} else {
result.add(new TestResult(AlertMessageLevel.ERROR, "注册企业", response.getResultCode(), response
.getResultMessage()));
} /**
* 功能描述:查询企业
* CustomerResponse getCustomerById(Integer id)
* 接口请求可以直接入参 案例
*/
//定义入参类型并赋值
Integer id=1;
//实例化一个响应
CustomerResponse response1 = new CustomerResponse();
//将定义参数传入被测接口方法
response1=CustomerInterface.getCustomerById(id);
//逻辑判断getResultCode是否10000
if (StringUtils.equals(response1.getResultCode(), ReturnResult.SUCCESS.getResultCode())) {
result.add(new TestResult(AlertMessageLevel.SUCCESS, "查询企业", response1.getResultCode(), response1
.getResultMessage()));
} else {
result.add(new TestResult(AlertMessageLevel.ERROR, "查询企业", response1.getResultCode(), response1
.getResultMessage()));
} /**
* 功能描述:根据名称和国家名称模糊匹配
* ShippingPortcodeResponse queryAllPortcodeCountry(java.util.Map<java.lang.String,java.lang.Object> paramMap)
* 接口请求带Map 案例
*/
Map<java.lang.String,java.lang.Object> wy = new HashMap<java.lang.String,java.lang.Object>();
wy.put("1", 1);
ShippingPortcodeResponse response2 = new ShippingPortcodeResponse();
response2 = ShippingPortcodeInterface.queryAllPortcodeCountry(wy);
if (StringUtils.equals(response2.getResultCode(), ReturnResult.SUCCESS.getResultCode())) {
result.add(new TestResult(AlertMessageLevel.SUCCESS, "根据名称和国家名称模糊匹配", response2.getResultCode(), response2
.getResultMessage()));
} else {
result.add(new TestResult(AlertMessageLevel.ERROR, "根据名称和国家名称模糊匹配", response2.getResultCode(), response2
.getResultMessage()));
} return result;
}}
接口测试中三种传参请求(Map、request、Integer)解析的更多相关文章
- C++学习3--编程基础(vector、string、三种传参)
知识点学习 Vector容器 vector是C++标准程序库中的一个类,其定义于头文件中,与其他STL组件一样,ventor属于STD名称空间: ventor是C++标准程序库里最基本的容器,设计之初 ...
- 浅谈C++三种传参方式
浅谈C++三种传参方式 C++给函数传参中,主要有三种方式:分别是值传递.指针传递和引用传递. 下面通过讲解和实例来说明三种方式的区别. 值传递 我们都知道,在函数定义括号中的参数是形参,是给函数内专 ...
- vector作为参数的三种传参方式
c++中常用的vector容器作为参数时,有三种传参方式,分别如下(为说明问题,用二维vector): function1(std::vector<std::vector<int> ...
- Vue-router的三种传参方式
第一种传递参数:name传参 两步完成name传参并显示在模板中: 第一在router/index.js中配置name属性, routes: [ { path: '/', name: 'HelloWo ...
- vue路由router的三种传参方式
方法三: 传参页面传递参数方式: this.$router.push({ path: 'indexTwoDetails', query: { "id": id } }) 接受参数页 ...
- vector做形参时的三种传参方式
vector在做形参的时候传参的方式和普通的变量是一样的,要么传值.要么传引用.要么传指针. 现在分别定义三个以vector为形参的函数: (1) fun1(vector <int> v) ...
- vue的三种传参方式
<template> <div> <router-link :to="{'name':'x',params:{'type':'users'}}"> ...
- c# 三种传参方式 in,out,ref
in:默认方式,传值不返回 out:不传值 但是会返回新值给予传参对象 ref:传存储地址,所以传参前必须赋值初始化,传值后的运算结果直接作用在传参上 Out和ref的效果差不多
- jquery mobile changepage的三种传参方法介绍
本来觉得changePage 那么多option,传几个参数应该没问题结果翻遍国内外网站,基本方法只有三种 1,显性传参,就是利用url这个地址把参数带上,然后到changepage后的新页面,用函数 ...
随机推荐
- c#中的正则表达式
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 前端实现QQ会话功能(常用笔记3)
<a href="tencent://message/?uin=客服QQ号码&Menu=yes" target="blank"></a ...
- html 组装table 指定列自动换行
4列后自动换行思路:int i = 0;while (dr.Read()){ if (i % 4 == 0) 输出一行的开始 输出这个数据 if (i % 4 == 3) 输出一行 ...
- MySQL MHA配置常见问题
MHA在MySQL数据库中被广泛使用,它小巧易用,功能强大,实现了基于MySQL replication架构的自手动主从故障转移,从库重定向到主库并自动同步.尽管如此,在部署配置的过程中,由于疏忽总难 ...
- 【C#】第2章学习要点
分类:C#.VS2015 创建日期:2016-06-15 教材:(十二五国家级规划教材)<C#程序设计及应用教程>(第3版) 一.本章要点 C#数据类型分两大类:值类型.引用类型. 值类型 ...
- windows下用eclipse+goclipse插件+gdb搭建go语言开发调试环境
windows下用eclipse+goclipse插件+gdb搭建go语言开发调试环境 http://rongmayisheng.com/post/windows%E4%B8%8B%E7%94%A ...
- [控件] 加强版 TOneSelection (改良自 Berlin 10.1 TSelection)
本控件修改自 Delphi Berlin 10.1 的 TSelection (FMX.Controls.pas) 修改重点: 移动点显示在上方 增加(左中,上中,右中,下中)控制点,含原来的总共有 ...
- Bug管理工具之Mantis_配置篇
角色管理员.经理.开发人员.修改人员.报告人员.查看人员,权限从大到小递减.分配: My View Settings 'assigned' => '1', 'unassigned' => ...
- Java IO 装饰者模式
装饰模式(Decorator) 装饰模式又名包装(Wrapper)模式. 装饰模式以对客户端透明的方式扩展对象的功能,是继承关系的一个替代方案. 装饰模式通过创建一个包装对象,也就是装饰,来包裹真实的 ...
- Code First :使用Entity. Framework编程(1) ----转发 收藏
这个是在学习EF CodeFirst时发现的,对于初学者还是不错的.果断转发,方便自己以后查阅和学习. 对于学习Code First 这个教程讲解的还是很详细. 第一章:欢迎来到Code First ...