JMeter CSV 数据配置为不同的线程选择不同的行
JMeter CSV Data Config choosing different rows for different Threads
我的 JMeter 测试包有 n 个线程。
线程需要从参数 (.csv) 文件中选取一个值,并使用相同的值执行 'x' 次。
如何让线程从 .csv 文件中选择不同的行并保留相同的行以供执行。
如果您想获得以下设置:
- 线程 1 始终使用 CSV 文件中的第 1 行
- 线程 2 始终使用 CSV 文件中的第 2 行
- 等等
最简单的方法是使用 __groovy() function 比如:
${__groovy(new File('/path/to/your/file.csv').readLines().get(ctx.getThreadNum()),)}
其中 ctx
代表 JMeterContext and ctx.getThreadNum()
function returns the number of current thread (virtual user), see Top 8 JMeter Java Classes You Should Be Using with Groovy 文章,了解有关使用此和其他 JMeter API 快捷方式的更多详细信息
我的 JMeter 测试包有 n 个线程。 线程需要从参数 (.csv) 文件中选取一个值,并使用相同的值执行 'x' 次。 如何让线程从 .csv 文件中选择不同的行并保留相同的行以供执行。
如果您想获得以下设置:
- 线程 1 始终使用 CSV 文件中的第 1 行
- 线程 2 始终使用 CSV 文件中的第 2 行
- 等等
最简单的方法是使用 __groovy() function 比如:
${__groovy(new File('/path/to/your/file.csv').readLines().get(ctx.getThreadNum()),)}
其中 ctx
代表 JMeterContext and ctx.getThreadNum()
function returns the number of current thread (virtual user), see Top 8 JMeter Java Classes You Should Be Using with Groovy 文章,了解有关使用此和其他 JMeter API 快捷方式的更多详细信息