如何在 Jmeter 中執行多個 if then 檢查相同的變數?我需要在 Jmeter 中實作以下 if then 條件:
if ${laiks} >=0 and ${laiks} <=85959 then ${OrderTime}=0
if ${laiks} >=90000 and ${laiks} <=105959 then ${OrderTime}=90000
if ${laiks} >=110000 and ${laiks} <=125959 then ${OrderTime}=110000
if ${laiks} >=130000 and ${laiks} <=152959 then ${OrderTime}=130000
if ${laiks} >=153000 and ${laiks} <=235959 then ${OrderTime}=153000
我創建了 5 個 IF 控制器,每個控制器都有自己的條件,但 Jmeter 總是將最后一個值 153000 分配給 ${OrderTime} 變數。
uj5u.com熱心網友回復:
如果您需要基于變數值創建OrderTime
JMeter 變數laiks
,最簡單的方法是使用合適的JSR223 測驗元素和以下Groovy代碼:
switch (vars.get('laiks') as int) {
case 0..85959:
vars.put('OrderTime', '0')
break
case 90000..105959:
vars.put('OrderTime', '90000')
break
//etc
default:
vars.put('OrderTime', '-1')
}
有關 JMeter 中的 Groovy 腳本的更多資訊:Apache Groovy:Groovy 的用途是什么?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/529472.html