Article directory
1. Description of the Duration Assertion parameter
可以控制取样器的执行是否超过某个时间,如果超时则报错,持续时间断言器也叫超时断言器
使用场景:我们一般用超时断言器来检测业务是否达到某个超时时间
使用频率:一般
Right click >>> Add >>> Assertion >>> Assertion duration (Duration Assertion)
Apply to
-
Main sample and sub-samples: Act on the parent node sampler and the corresponding child node sampler; assert all samplers
-
Main sample only: only acts on the parent node sampler; asserts only on the main sampler
-
Sub-samples only: only applies to sub-node samplers; asserts only on sub-samplers (sub-samplers: original samplers, processed by post-processors, and obtain request results)
Duration to Assert (assertion duration)
- Duration in milliseconds (duration (milliseconds)): assertion execution time
2. Test plan design
(1), right click on the test plan <<< add <<< thread (user) <<< thread group
-
Number of cycles: 10
-
Other parameters can be default
(2), right click on the thread group <<< add <<< sampler <<< JSR223 Sampler
log.info("我是:JSR223 Sampler");
(3), right click on the thread group <<< add <<< assertion <<< assertion duration
- Duration (ms): 100
(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 request information
如图,取样器都请求成功,断言成功
(6), modify JSR223 Sampler
- language: java
log.info("我是:JSR223 Sampler");
Thread.sleep(1000L);
(7) Click to clear all, click to start, click to view the result tree, and view the request information
如图,取样器都请求失败,断言失败;断言持续时间 中给出了失败原因