购物商城接口测试案例

1、接口说明:

调用商品到购物车接口

2、请求方式:

HTTP POST请求

3. 接口地址:

/ecshop/upload/flow.php?step=add_to_cart

4. 请求参数:

1) 输入参数:

JMeter接口测试之HTTP Post请求实例

JSON数据格式:
JMeter接口测试之HTTP Post请求实例_第1张图片

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) 响应参数:

JMeter接口测试之HTTP Post请求实例_第2张图片

2) 响应示例:

JMeter接口测试之HTTP Post请求实例_第3张图片

测试步骤

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配置

JMeter接口测试之HTTP Post请求实例_第4张图片
请求参数一般放在“Body data”选项卡中:
goods={"quick":1,"spec":
["237"],"goods_id":1,"number":"1","parent":0}
本例中请求参数为查询字符串,因此还可以放在“Parameters“选项卡中:
JMeter接口测试之HTTP Post请求实例_第5张图片