您可以使用即Size Assertion或Response Assertion標記空白請求爲失敗的。
如果你只是需要只是數字,而沒有要記錄在空白的回答,我會建議使用BeanShell的後處理器如下故障。
- 定義一個用戶定義的變量稱爲即
blank
與0
- 的值的BeanShell的後處理器添加到其可產生空白響應
- 在其端部將報告最終的每個請求添加BeanShell的採樣器可變
實施例後處理器代碼:
int blank = Integer.parseInt(vars.get("blank")); //get current "blank" variable value
String response = new String(data); //get response data as string
if (response.length() == 0) // if response length equals zero (feel free to update this as requred)
{
blank++; // increment "blank" variable
}
vars.put("blank", String.valueOf(blank)); // update "blank" variable value
實例最終的BeanShell取樣代碼:
log.info("Pages with blank response count: " + vars.get("blank")); // print current "blank" variable value to "jmeter.log" file
你應該看到類似下面的jmeter.log文件:
2014年5月15日18點36分34秒INFO - jmeter.util.BeanShellTestElement :頁面 空白應答次數:15
2014年5月15日18時36分34秒INFO - jmeter.threads.JMeterThread:線程完成:線程1-1組 2014年5月15日18:36: 34 INFO - jmeter.engine.StandardJMeterEngine: 測試結束
2014年5月15日18時36分34秒的INFO通知測試聽衆 - jmeter.gui.util.JMeterMenuBar:setRunning(假的,本地)
參見How to use BeanShell: JMeter's favorite built-in component指南JMeter的擴展與腳本演練和一種Beanshell食譜。