壓力測試使用 Playwright 與 Artillery (入門篇)

Load testing with Playwright and Artillery. stress testing.

參考文件(入門必讀)

簡介

Artilleryarrow-up-right was designed with best practices for modern production-engineering in mind. Test at cloud-scale, test any stack, and go from zero to production-grade testing fast.

Playwrightarrow-up-right is a modern browser automation framework by Microsoft. Artillery supports running Playwright-based scripts as load tests, including running Playwright at scalearrow-up-right using AWS Fargate

試用心得感想

Artillery+Playwright工具將組建機器人打開 Chrome 並依設定好的 test-flow 測試程序來操作介面,填入欄位值、按下按鍵送出等。

Playwright負責 test-flow 操作網頁。

Artillery是執行框架。

  • Test functions have to be written in Javascript (if you have existing Playwright code in TypeScript, it will need to be transpiled to JS first)

  • Only Chrome is available. Restricting the integration to just one browser improves startup time performance for large load tests and does not have any consequential effects on the results of load tests themselves.

測試需求

進行 WebApp 基本的壓力測試。測試對象為登入畫面。

安裝紀錄

撰寫測試流程程式碼

用檔案總管找個地方建立測試工作的目錄以利於管理。並加入二個檔案。

一、artillery-test-script.yml ——— An Artillery test script is a YAML filearrow-up-right . 內容其實是組態檔。最簡單的測試流程比如呼叫單一 WebAPI 的情境就不需另外寫 test-flow。

二、test-flow.js ——— 用 JavaScript 撰寫測試程序。大部份的真實場景還是要寫 test-flow。

程式碼記錄

下面是練習用例子,還不夠真實。謹可以入門參考。

執行測試

執行期間會真的打開 browser ,並依給序的程序機械化的操作介面。

(EOF)

Last updated