JMeter-在脚本中提交JMeter函数(JSR223元素) [英] JMeter - submit JMeter function inside a script (JSR223 element)

查看:332
本文介绍了JMeter-在脚本中提交JMeter函数(JSR223元素)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

函数对于编写功能脚本非常有用,而且在无需编写实际代码的情况下也很有帮助.

Functions are very useful for writing a functional script and also helpful without writing real code.

目前,我可以在大多数测试计划中执行功能,除了JSR223 Sampler的脚本外.

Currently I can execute functions in most of Test Plan except in Script of JSR223 Sampler for example.

有没有一种方法可以在JSR223/Beanshell脚本中启用JMeter功能? 例如$ {__ log(Message)}或$ {__ Random(0,10)}

Is there a way to enable JMeter function inside JSR223/Beanshell script? For example ${__log(Message)} or ${__Random(0,10)}

如果将变量作为$ {..}的调用存在问题,那么是否存在解决方法来调用函数?

If the call for variable as ${..} is an issue, is there a workaround for calling a function?

在groovy脚本中调用groovy函数可能会出现问题,但是可以执行其他功能吗?

Maybe there will be a problem calling groovy function inside groovy script, But can other functions be executed?

推荐答案

不应内联

You should not be inlining JMeter functions and/or Variables into scripts as :

  • They might resolve into something causing compilation failure or unexpected behavior
  • In case of Groovy they will conflict with GStringTemplate, moreover compiled scripts caching will not be possible

因此,您有2个选择:

  1. 使用 JSR223测试元素的参数"部分喜欢:

  1. Use "Parameters" section of the JSR223 Test Elements like:

使用基于代码的等效项,即使用 RandomUtils 类:

Go for code-based equivalents, i.e. using RandomUtils class:

更多信息: Apache Groovy-为什么和如何使用它

这篇关于JMeter-在脚本中提交JMeter函数(JSR223元素)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆