我試圖創建一個測試計劃,當達到某個值時,然後發生一些功能。測試計劃由多個以循環運行的線程組成,當達到某些條件時,我想發起HTTP請求。我會在下面討論它的內核: 在我的測試中,我有多線程循環方式的邏輯,當條件滿足時(條件每10秒滿足一次),那麼我需要迭代通過一個值,它的價值應該從以前的迭代保存 - 我定義的值是一個屬性(user.properties
) - startIndex = 0
(初始化爲0)。 所以我做了一個While Controller
它的狀況是這樣的:JMeter循環索引和屬性更新
${__javaScript(${__P(startIndex,)}<=${currBulk},)}
我期待的HTTP請求,這依賴於內部,而價值startIndex
要當startIndex<=currBulk
變量執行。
的While Controller
裏面的HTTP請求應該被解僱,直到所有的指標都包括在內,我都寫過這樣的內部BeanShell PostProcessor
:
int startIndexIncInt = Integer.parseInt(props.getProperty("startIndex")); //get the initiated index of the loop
startIndexIncInt = startIndexIncInt + 1; //increment it and see if needed to fire the request again, by the original While condition
vars.put("startIndexIncIntVar", String.valueOf(startIndexIncInt));
props.put("startIndex",vars.get("startIndexIncIntVar")); //the property incremental and update
所以,我爲了把它設計一樣,在下一時間(10秒後)我將更新startIndex
,這將與新的currBulk
(它總是由我的測試計劃更新)進行比較。 而我只是不能完成它。我不斷收到類似的錯誤:
startIndexIncInt = Integer.parseInt(props.ge . . . '' : Typed variable declaration : Method Invocation Integer.parseInt
不用說,我也定義不設置好的了var startIndexIncIntVar
(我通過調試取樣檢查)。 此外,我的問題是沒有與時間進入while,我的問題基本上是我應該增量和使用我的HTTP請求(while條件,和beanshell後處理器腳本)的變量
只爲更多它的信息,如果我寫它的僞代碼它應該是這樣的:
startInc = 0
----Test plan loop----
------ test logic, currBulk incremented through the test-----
if(time condition to enter while){
while (startIndex <= currBulk){
Send HTTP request (the request depends on startIndex value)
startIndex++
}
}
請協助