groovy ctx上下文简单使用教程
目录
ctx
本文主要介绍ctx的简单用法.
如同个线程组里面的前一个HTTP Request的response信息.
本文需要添加:
- 两个Sampler
- 添加一份代码
ctx简单介绍
- API: https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html
- ctx: JMeterContext — jmeter当前线程的上下文
- The class is not thread-safe - it is only intended for use within a single thread.(单个线程里面使用)
1.0 添加Sampler: HTTP Request
Thread Group -> Sampler -> HTTP Request
- Server Name or IP: www.baidu.com
- 其他默认即可
1.1 添加Sampler: JSR223 Sampler
ctx在这个Sampler中使用, 获取上一个Sampler的request和reponse信息
Thread Group -> Sampler -> JSR223 Sampler
1.0 ctx获取request和response信息
结果
总结
- ctx: JMeterContext — jmeter当前线程的上下文
- ctx只能在当个线程里起作用
- ctx用来控制线程组
- ctx用来获取同个线程组内上一个Sampler的reponse和request
公众号回复: groovy, 获取相关jmeter脚本
扫码关注公众号: 风起帆扬了
来一起学习,成长,分享
航行在测试的大道上
喜欢就点赞吧