[P48] JMeter assertion duration (Duration Assertion)


1. Description of the Duration Assertion parameter

可以控制取样器的执行是否超过某个时间,如果超时则报错,持续时间断言器也叫超时断言器

使用场景:我们一般用超时断言器来检测业务是否达到某个超时时间

使用频率:一般

Right click >>> Add >>> Assertion >>> Assertion duration (Duration Assertion)

insert image description here

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

insert image description here

  • Number of cycles: 10

  • Other parameters can be default

(2), right click on the thread group <<< add <<< sampler <<< JSR223 Sampler

insert image description here

log.info("我是:JSR223 Sampler");

(3), right click on the thread group <<< add <<< assertion <<< assertion duration

insert image description here

  • 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

insert image description here

如图,取样器都请求成功,断言成功

(6), modify JSR223 Sampler

insert image description here

  • 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

insert image description here

如图,取样器都请求失败,断言失败;断言持续时间 中给出了失败原因

Guess you like

Origin blog.csdn.net/qq_45138120/article/details/131030449