2017-08-31 74 views
1

嘗試在腳本中放置一些條件邏輯,以僅基於成功驗證響應斷言來執行某些步驟。Jmeter - 基於響應斷言結果執行代碼

我的腳本: 主要執行線程

- Submit Http request 
-- Response assertion code 200 (indicates request successfully submitted) 
-- Response assertion contains string (I expect a specific string back if successful) 
-- Json extractor (extract the string I tested for in the response for later use) 
- Do a bunch of other stuff 

我的問題是,我只想要執行「等一堆東西,」如果我能找回期望的字符串(沒有它,一切都會反正失敗)。

我需要一個條件測試才能執行,如果第二個響應斷言通過。

我一直在使用"${JmeterThread.last_sample_ok}"嘗試,但這個給我,我假設我已經放在了「如果」在錯誤的點,或者只是使用的條件不適當的If controller: error while processing ... BAD CONDITION...expected true or false

錯誤。

有什麼建議嗎?

UPDATE:

我的劇本目前看起來是這樣的:

- If test record is version 0 
-- Send http to version 0 api 
--- Response code assertion 200 
--- Response assertion message contains specific string 
--- Json extractor to extract the data associated with the string 
-- If "${JmeterThread.last_sample_ok}" 
--- Do other stuff 

我假設我已經放在瞭如果包含「最後一個樣本OK」在錯誤的水平,或者說,其實有作爲最後一個步驟的json提取器會讓事情變得不安。

+0

你能證明你如果控制器? –

+0

更新的主要說明 – Tufty

+0

請顯示組件的屏幕截圖如果控制器,而不是僞代碼。 thx –

回答

1

你犯了一個錯誤。代碼是「區分大小寫」。

這裏是If Controller應如何進行配置:

enter image description here

+0

謝謝。我從中複製的例子有錯誤的地方。覺得我需要在這裏的facepalm表情符號! – Tufty