jmeter entry notes a controller

@@@@@@@@@@

You add me, do not chat with me, do not give me praise, do not hook up to me, you are looking for a chance to plot against me ah

  Today the record about some of the ideas of talent when using the controller. There are many logic controller in jmeter, the role of the individual in accordance with the official explanation is appreciated: better control the execution order requested by the controller. Similar cross the road, walking in the request only when the green light, red light can not take a reason. jmeter logic controller drill a look there are many, in fact, commonly had a few, but to understand the logic controller is also very simple, we do not need to memorize, understand the working mechanisms of the future when needed Baidu check how to use the controller It can be. Today to talk about doing a few simple common notes.

1 simple controller

  No practical effect, I found only role is currently classified, equivalent to the role of the folder, create a simple controller = New Folder. Folders can be doing everyone you know, if the thread group likened the C drive, the C disk that simple controller is a folder, the folder can continue to create a new file

2 only one controller

  As the name implies, under the request of the controller, only once. The actual scene of the first reaction is landing, because every time we login into the system, the first thing, but we will only landed once, subsequent operations do not need to log in, this scenario can be simulated by only one controller implementation

3 cycler

  In this request the controller, based on the number of cycles performed several times request cycles, similar cycles, like the thread group, it is noted that, if the thread group setting performed three times, the inner loop controller setting the thread group is executed twice, since then the relationship is a thread group that contains the controller logically, so in the end this request will perform 3 * 2 = 6 times, to understand the mechanism of this control should not be difficult to understand.

4 If the controller

  At the request of this controller, if the need to meet the conditions will be implemented, simply, if the landing is successful, the implementation of attendance, can be achieved by this request, we can set to control the condition if we are requested to perform at what time . In fact most of the logic controller is provided to control execution of the request by the condition, the nature of which is the logic controller.

 These are the centralized logic controller interface, it is easy to understand and in fact there is nothing complex content, a recording controller uses the simplest scenario: user login system (login request), after the successful landing punch (punch request) twice

思路:登录放在第一个文件夹,打卡放在第二个文件夹,登录仅执行一次;打卡需要判断,如果登录成功,则循环执行打卡2两次。根据思路用jmeter实现步骤如下:

1新增两个简单控制器,分别存放两个请求

2在登录文件夹添加进一次控制器,并将登录请求放在仅一次控制器下

 

 3在打卡文件夹中添加如果控制器,设置判断条件为登录成功,思路为判断登录请求是否成功

 4在如果控制器下添加循环控制器,设置循环次数为两次,并添加打卡请求

 

   按照顺序,程序执行顺序为:登录一次-如果登录成功则进入循环控制器,执行打卡两次的操作。如此便模拟出上述业务场景。其实这个场景可以有更简便的写法,这里只是用这个例子来说明控制器的作用和用法。

  jmeter其他逻辑控制器还有很多,这里就不一一详述,其他控制器教以上四个来说更为复杂,可以解决很多复杂的业务场景,但是其本质逻辑是与上面控制器一致的,实际使用需要根据场景选择需要用到的控制器,不仅仅方便管理请求,维护代码,而且能更真实的模拟实际场景,对性能测试,流程测试都是极为有利的。

--  以上内容均为笔者原创,转载请注明出处,如有不当欢迎指正~

Guess you like

Origin www.cnblogs.com/baxiaobin/p/12132106.html