rest - How to take values of Jmeter variable in coma separated way
问题描述
I'm hitting a rest Api through http GET request in jmeter. the url is like http://hostName:port/searchParameter=value1,value2,value3
the value1, value2 ... are taken from a file which is like
File.csv value1 value2 value3
this csv file is not really coma seperated values they are in separate lines. Now how to achieve this
解决方案
JMeter doesn't provide a suitable test element so you will have to go for __groovy() function and some custom scripting.
I can think of using File.readLines() function to read the contents of your file into memory followed by join() function to convert the array into a comma-separated string.
The final syntax would be:
${__groovy(new File('File.csv').readLines().join('\,'),)}
Demo:
Check out Apache JMeter Functions - An Introduction article to get familiarized with JMeter Functions concept.
推荐阅读
- reactjs - 更新的默认值未以 React 钩子形式加载
- lua - iso 8601 日期时间格式为 hh:mm - 然后加/减分钟
- dicom - 如何显示来自 DICOM C-FIND 结果的系列数据?
- excel - 我可以将 Text to Columns 函数的目标设置为数组吗?
- javascript - 使用 javascript 获取 rawg API 导致错误
- apache-flink - 你可以从 Apache Flink 操作符访问 isBackPressure 吗?
- r - 双几何 - 在非 sf 列上加入空间 dfs 并摆脱额外的几何
- android - 无法从带有后缀 HEAD-SNAPSHOT 的库中添加依赖项
- python - 已解决:使用 Discord.py API 解决的“RuntimeError:事件循环已关闭”
- python-3.x - 如何使用python获取任务标题