Jmeter简单的登录压力测试(使用json发送post请求)

1:创建一个线程组

Jmeter简单的登录压力测试(使用json发送post请求)

2:设置线程组参数

Jmeter简单的登录压力测试(使用json发送post请求)

3:添加http请求

Jmeter简单的登录压力测试(使用json发送post请求)

4:修改http请求的内容

Jmeter简单的登录压力测试(使用json发送post请求)

5:发送的是json数据的http请求,需要添加HTTP Header Manager

Jmeter简单的登录压力测试(使用json发送post请求)

6:修改HTTP Header Manager信息

Jmeter简单的登录压力测试(使用json发送post请求)

7:添加断言(响应断言[Response Assertion])

Jmeter简单的登录压力测试(使用json发送post请求)

8:修改Response Assertion的内容

Jmeter简单的登录压力测试(使用json发送post请求)

说明:

Apply to:指定断言作用范围。

Main sample and sub-sample:作用于主main sample和子sub-sample

Main sample only:只作用于main sample

Sub-samples only:只作用于sub-sample

JMeter Variable:作用于JMeter变量

注意:

1、大多数情况下,可只勾选“main sample only”,因为一般情况下,发起一个请求,实际就只有一个请求。但是在某些情况下,发起一个请求时,会触发多个服务器请求,这时候就有main sample和sub-sample之分,类似ajax请求,另外,如果发起重定向请求,并且勾选“跟随重定向”,则把重定向后的请求视为main-sample

2、如果sub-sample断言失败,但main sample断言成功,那么main sample也被设置为失败状态。如果作用域JMeter变量,且该变量关联main sample,那么如果断言失败,则main sample也被设置为失败(If the JMeter variable option is used, it is assumed to relate to the main sample, and any failure will be applied to the main sample only)。

3.如果执行完每个sampler的所有断言,变量JMeterThread.last_sample_ok会被设置为true或false

要测试的响应字段:

 响应文本(Text Response) -从服务器返回的响应文本,比如body,包含HTTP头

 Document(text) -通过Apache Tika追踪的各种各种类型文档的文本

 URL样本

 响应代码(Response Code) -比如200,201,400,1000,1001

 响应消息(Response Message) -比如OK,Fail

 Response Headers -响应头,包括Set-Cookie头,如果有的话

 Ignore Status -指示JMeter设置sampler status的初始状态为success。sample status是否成功,由已Response status和断言结果决定,当选中Ignore Status时,Response status被强制设置为success,不执行进一步的断言判断。仅第一次断言时使用。

Jmeter简单的登录压力测试(使用json发送post请求)

8 添加监听器(察看结果树)

Jmeter简单的登录压力测试(使用json发送post请求)

9:点击执行后察看结果树(执行均通过)

Jmeter简单的登录压力测试(使用json发送post请求)