天天看點

性能測試——Jmeter( Mac & Cent OS )

JMeter介紹 

Apache JMeter是Apache組織開發的基于Java的壓力測試工具。用于對軟體做壓力測試,它最初被設計用于Web應用測試,但後來擴充到其他測試領域。 它可以用于測試靜态和動态資源,例如靜态檔案、小程式、CGI 腳本、Java 對象、資料庫、FTP伺服器等等

JMeter安裝

在終端輸入以下代碼進行安裝

brew install jmeter      

然後輸入以下代碼打開jmeter;或者直接找到/usr/local/bin檔案夾,然後單擊jmeter打開

open /usr/local/bin/jmeter      

終端執行出現下圖内容則安裝成功

jmeter -v      
性能測試——Jmeter( Mac & Cent OS )

啟動JMeter 

  • 執行​

    ​jmeter​

    ​,将啟動JMeter,在終端會有如下輸出:
  • 性能測試——Jmeter( Mac & Cent OS )
  • 可操作菜單Options => Choose Language => Chinese 進行中文語言的切換:
  • 性能測試——Jmeter( Mac & Cent OS )

建立測試計劃

  • 右鍵Test plan 選擇線程組
性能測試——Jmeter( Mac & Cent OS )
  • 填寫3000線程數
性能測試——Jmeter( Mac & Cent OS )
  • 右鍵線程組找到HTTP請求
性能測試——Jmeter( Mac & Cent OS )
  • 填寫HTTP請求 GET  測試域名​​https://ch3nnn.cn/​​
性能測試——Jmeter( Mac & Cent OS )
  • 右鍵線程組找到響應斷言
性能測試——Jmeter( Mac & Cent OS )
  • 選擇響應代碼  填寫200 成功狀态碼
性能測試——Jmeter( Mac & Cent OS )
  • 右鍵找到察看結果樹
性能測試——Jmeter( Mac & Cent OS )

點選啟動

性能測試——Jmeter( Mac & Cent OS )
  • 點選儲存,測試計劃建立完成
  • 性能測試——Jmeter( Mac & Cent OS )

運作測試計劃

執行指令

jmeter -n -t ./察看結果樹.jmx -l result.txt -e -o report


# Test_plan.jmx:測試計劃檔案
# result.txt:測試記錄
# report:測試報告儲存目錄