购物商城接口测试案例
1、接口说明:
调用商品到购物车接口
2、请求方式:
HTTP POST请求
3. 接口地址:
/ecshop/upload/flow.php?step=add_to_cart
4. 请求参数:
1) 输入参数:
JSON数据格式:
2) 请求示例:
POST /ecshop/upload/flow.php?step=add_to_cart
HTTP/1.1
Host: 192.168.126.134
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64;
rv:35.0) Gecko/20100101 Firefox/35.0
Accept:
text/html,application/xhtml+xml,application/xml;q=0.
9,/;q=0.8
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded;
charset=UTF-8
Referer:
http://192.168.126.134/ecshop/upload/goods.php?id=1
Content-Length: 69
Cookie: ECS[history]=1%2C17%2C9%2C5%2C8;
ECS[display]=grid; ECS[visit_times]=2;
ECS_ID=e1d0459a234edc14230c8e8c3f12251bb699bd86
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
goods={"quick":1,"spec":
["237"],"goods_id":1,"number":"1","parent":0}
5. 返回参数
1) 响应参数:
2) 响应示例:
测试步骤
1.在“Test Plan”节点上右键,选择Add-->Threads(users)--
Thread Group;
2.在“Thread Group”节点上右键,选择Add-->Sampler-->HTTP
Request;
3.在“HTTP Request”节点上右键,选择Add-->Listener-->View
Results Tree;
4.选中“HTTP Request”对HTTP请求进行配置;
5.点击“Save”,保存测试计划;
6.点击“Start”,运行JMeter测试
HTTP Request配置
请求参数一般放在“Body data”选项卡中:
goods={"quick":1,"spec":
["237"],"goods_id":1,"number":"1","parent":0}
本例中请求参数为查询字符串,因此还可以放在“Parameters“选项卡中:
来源:51CTO
作者:szchuanshi
链接:https://blog.51cto.com/14645850/2462408