Jmeter基础系列(四)JMeter测试HTTP POST

4.1 HTTP Request(POST)

参见JMeter必知必会系列(3) 3.2章节内容,不再赘述。

4.2 应用案例

测试案例说明

1.接口说明

加入商品到购物车接口。

2. 请求方式

HTTP POST请求。

3. 接口地址

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

4. 请求参数

1)请求参数:

Jmeter基础系列(四)JMeter测试HTTP POST_第1张图片

image

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基础系列(四)JMeter测试HTTP POST_第2张图片

image

  1. 响应示例:

 

HTTP/1.1 200 OK
Date: Wed, 19 Jun 2019 03:16:29 GMT
Server: Apache/2.2.21 (Unix) PHP/5.3.29
X-Powered-By: PHP/5.3.29
Cache-control: private
Content-Length: 273
Keep-Alive: timeout=5, max=88
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8

{"error":0,"message":"","content":"\u60a8\u7684\u8d2d\u7269\u8f66\u4e2d\u6709 2 \u4ef6\u5546\u54c1\uff0c\u603b\u8ba1\u91d1\u989d \uffe53503.60\u5143\u3002<\/a>","goods_id":"","one_step_buy":0,"confirm_type":"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基础系列(四)JMeter测试HTTP POST_第3张图片

image

也可以将参数放在“Parameters”选项卡中:

Jmeter基础系列(四)JMeter测试HTTP POST_第4张图片


 

你可能感兴趣的:(jmeter,jmeter)