Article directory
1. Once Only Controller (Once Only Controller) parameter description
可以让控制器内部的逻辑只执行一次;单次的范围是针对某一个线程,无论线程外面迭代多少次或者里面循环多少次,均只执行一次;单次控制器一般可用于登陆,全局参数设置这种只执行一次的逻辑控制
Right-click on the thread group >>> Add >>> Logic Controller >>> Once Only Controller
2. Test plan design
2.1. Test plan one
(1), right click on the test plan <<< add <<< thread (user) <<< thread group
-
Number of cycles: 6
-
Other parameters can be default
(2), right click on the thread group <<< add <<< logic controller <<< only once controller
(3), only one right click on the controller <<< add <<< sampler <<< debug sampler
- The parameters are default
(4), right click on the thread group <<< add <<< listener <<< view the result tree
(5) Click to start, click to view the result tree, and view the sampler request
如图,调试取样器请求成功,但只执行一次。仅一次控制器下的取样器,只执行一次
2.1. Test Plan II
(1), right click on the test plan <<< add <<< thread (user) <<< thread group
- The parameters are default
(2), right click on the thread group <<< add <<< logic controller <<< cycle controller
- Number of cycles: 6
(3), right click on the cycle controller <<< add <<< sampler <<< debug sampler
- Name: Debug Sampler-1
(4), right click on the cycle controller <<< add <<< logic controller <<< only once controller
(5), only one right click on the controller <<< add <<< sampler <<< debug sampler
- Name: Debug Sampler-2
(6), right click on thread group <<< add <<< listener <<< view result tree
(7) Click to start, click to view the result tree, and view the sampler request
如图,循环控制器 下的 调试取样器-1 循环执行了6次,而 循环控制器 下的 仅一次控制器 下的 调试取样器-2 只执行了1次
(8), modify the loop controller, set the number of loops to 0
- Number of loops: 0
(9), click Clear All, click Start, click Cycle Controller, and view the sampler request
如图,两个 调试取样器 都未执行
根据执行顺序,找到取样器后,再依次执行逻辑控制器,但是 循环控制器 的循环次数设置为0,它不会执行 循环控制器 下的所有组件