Jmeter JSR322 在 while 循环中
Jmeter JSR322 inside a while loop
我无法弄清楚我的 Jmeter 线程出了什么问题或哪里出了问题。如您所见here this my dynamic request that calls specific variables that I need. And this is the conditions I added in my while loop that I called from the Destination csv.
我的目标是根据 state/city/zipcode 提取税率,因此我创建了一个 JSR322 后处理器脚本来提取正确的税率。这是 picture and here and finally the condition. The next procedure would be a Json Assertion.
我的问题是当循环是 运行 时,整个循环都使用从税率文件中提取的第一个变量。这是我创建的 Flow chart,可以帮助您理解我的流程。
TLDR:
提取的第一个变量将在整个循环中使用。但它不应该:\
不要将 JMeter 函数或变量内联到 Groovy 脚本中。
根据 JSR223 Sampler 文档:
The JSR223 test elements have a feature (compilation) that can significantly increase performance. To benefit from this feature:
- Use Script files instead of inlining them. This will make JMeter compile them if this feature is available on ScriptEngine and cache them.
- Or Use Script Text and check Cache compiled script if available property.
When using this feature, ensure your script code does not use JMeter variables or JMeter function calls directly in script code as caching would only cache first replacement. Instead use script parameters.
所以改变所有的东西,比如:
`${order__items__destination__stateOrProvince}`
到
vars.get('order__items__destination__stateOrProvince')
它应该会按预期开始工作。
有关 JMeter 中 Groovy 脚本的更多信息:Apache Groovy - Why and How You Should Use It
我无法弄清楚我的 Jmeter 线程出了什么问题或哪里出了问题。如您所见here this my dynamic request that calls specific variables that I need. And this is the conditions I added in my while loop that I called from the Destination csv.
我的目标是根据 state/city/zipcode 提取税率,因此我创建了一个 JSR322 后处理器脚本来提取正确的税率。这是 picture and here and finally the condition. The next procedure would be a Json Assertion.
我的问题是当循环是 运行 时,整个循环都使用从税率文件中提取的第一个变量。这是我创建的 Flow chart,可以帮助您理解我的流程。
TLDR:
提取的第一个变量将在整个循环中使用。但它不应该:\
不要将 JMeter 函数或变量内联到 Groovy 脚本中。
根据 JSR223 Sampler 文档:
The JSR223 test elements have a feature (compilation) that can significantly increase performance. To benefit from this feature:
- Use Script files instead of inlining them. This will make JMeter compile them if this feature is available on ScriptEngine and cache them.
- Or Use Script Text and check Cache compiled script if available property.
When using this feature, ensure your script code does not use JMeter variables or JMeter function calls directly in script code as caching would only cache first replacement. Instead use script parameters.
所以改变所有的东西,比如:
`${order__items__destination__stateOrProvince}`
到
vars.get('order__items__destination__stateOrProvince')
它应该会按预期开始工作。
有关 JMeter 中 Groovy 脚本的更多信息:Apache Groovy - Why and How You Should Use It