Another way Jmeter separate login affairs

Recently, I met a lot of people plagued by problems.

Scenarios are as follows:

  Business Process: Sign a website, repeatedly recharge.

  The usual practice is to use jmeter login interface and recharge repeated execution:

 

 

But the method can not achieve a perfect fit business processes.

And, during the pressure test of time, the total can not log on interfaces with the pressure of it, therefore, we need to use the jmeter logic controller.

 

Logic Controller

That is what logic controller it?

Jmeter official website explanation of the logic control is: Logic the Controllers the Determine the Order in Which Samplers are at The Processed.

Translate: control logic may control the order of execution of the sampler (Samplers) a.

So, Show time !!!

 

1, thread group -> Add -> Logic Controller -> Only one controller

ps: If it is the English version of jmeter, Thread Group-> add-> logic Controller-> Once Only Controller

Concept: During the test program, under the sub-node controller is performed only once for each thread

 

2, the interface was added only once at the request controller

This, implement the login interface run

(Ps: The figure shows a login interface is the only controller in the following)

 

 

3, the thread group -> Add -> Logic Controller -> cycler

ps: If it is the English version of jmeter, Thread Group-> add-> logic Controller-> Loop Controller

Concept: Specifies the number of its child nodes running, specific numerical values ​​may be used (see below, is set to 4 times), variables can be used

 

 

4, is added at the request recharge cycle control

And set the number of cycles to this, namely to achieve a cycle log in once but many times recharge the purpose of the implementation of the interface.

(Ps: seen, the recharge cycle in the interface controller below)

 

 

 

5, run see the results tree, perfect!

 

Emphasis

Focus here, knock on the blackboard the teacher, ah!

Loop controller:

1, is always the option: check on this one represents the loop forever

2、如果同时设置了线程组的循环次数和循环控制器的循环次数,那循环控制器的下面的接口运行的次数为两个数值相乘的结果。

仅一次控制器:

将仅一次控制器作为循环控制器的子节点,仅一次控制器在每次循环的第一次迭代时均会被执行。

情景如下:

  业务流程:登录一个网站,反复进行充值。

  通常的做法是使用jmeter对登录和充值的接口进行反复的执行:

 

 

但是实现的方法却不能完美的贴合业务流程。

并且,在进行压测的时候,总不可能把登录接口也一起压了吧,因此,就需要用到jmeter的逻辑控制器了。

 

逻辑控制器

那啥是逻辑控制器呢?

Jmeter官网对逻辑控制的解释是:Logic Controllers determine the order in which Samplers are processed。

翻译一下:逻辑控制可以控制采样器(samplers)的执行顺序。

那么,Show time!!!

 

1、线程组->添加->逻辑控制器->仅一次控制器

ps:如果是英文版的jmeter,Thread Group->add->logic Controller->Once Only Controller

概念:测试计划执行期间,该控制器下的子结点对每个线程只执行一次

 

2、在仅一次控制器下添加接口请求

到此,实现登录接口的一次运行

(ps:由图可见,登录接口是在仅一次控制器下面的)

 

 

3、线程组->添加->逻辑控制器->循环控制器

ps:如果是英文版的jmeter,Thread Group->add->logic Controller->Loop Controller

概念:指定其子节点运行的次数,可以使用具体的数值(如下图,设置为4次),也可以使用变量

 

 

4、在循环控制下添加充值请求

并设置循环次数,到此,即实现了登录一次却循环执行了多次充值接口的目的。

(ps:由图可见,充值接口是在循环控制器下面的)

 

 

 

5、运行察看结果树,完美!

 

重点

重点来了,老师敲黑板了啊!

循环控制器:

1、永远选项:勾选上这一项表示一直循环下去

2、如果同时设置了线程组的循环次数和循环控制器的循环次数,那循环控制器的下面的接口运行的次数为两个数值相乘的结果。

仅一次控制器:

将仅一次控制器作为循环控制器的子节点,仅一次控制器在每次循环的第一次迭代时均会被执行。

Guess you like

Origin www.cnblogs.com/wuzm/p/11317768.html