某地兒見到別人推薦的講自動化測試框架的書,雖然老了點兒,可是基本原理啥的講的清清楚楚明明白白,因此讀之。
原書連接在此,只有英文版,只有電子版:
http://safsdev.sourceforge.net/FRAMESDataDrivenTestAutomationFrameworks.htmapp
這就是個讀書筆記,想好好理解的話仍是去看原文。部分標題,我本身給出了不大順溜的翻譯,請以原文爲準。
## 1.1 Thinking Past "The Project" (思考不要侷限在一個項目上)
不能期望來一個項目,就對應的作一個自動化測試框架,須要開發一個獨立與項目之上的框架。 框架
#### 1.1.1 Problems With Test Automation. A CASE STUDY
講了一個失敗的例子。
有個大公司1996年開始評估自動化工具,並在1998年購買了一款商用自動化工具投入使用。
該公司的項目都是獨立運做的,因此自動化項目也是獨立的,所以每一個項目有各自的腳本,各項目也各自寫了本身項目的公共庫,等。
而當各項目的程序有變化時,腳本須要維護;自動化工具升級時,可能會形成腳本失敗,就須要維護甚至降級自動化工具。
無休止的這種維護支出,最終致使了自動化項目的被擱淺。
#### 1.1.2 Some Test Strategy Guidelines
教訓:必須開發可重用的測試策略。
- Test automation is a fulltime effort, not a sideline.
- The test design and the test framework are totally separate entities.
- The test framework should be application-independent.
- The test framework must be easy to expand, maintain, and perpetuate.
- The test strategy/design vocabulary should be framework independent.
- The test strategy/design should remove most testers from the complexities of the test framework.ide
## 1.2 Data Driven Automation Frameworks(數據驅動自動化框架)
#### 1.2.1 Data Driven Scripts.
依靠數據驅動腳本的測試自動化框架,是最容易和最快執行的,若是有技術人員來持續維護的話。
但維護它是比較困難的,常常會致使長期的失敗。
#### 1.2.2 Keyword or Table Driven Test Automation
至今爲止的討論代表,關鍵字驅動的測試自動化是比較理想的自動化框架。有時也稱之爲"表格驅動"測試自動化。 工具
**Action, Input Data, and Expected Result ALL in One Record:**
例如,驗證登陸頁面上的用戶名,咱們可能有以下數據表:
WINDOW | COMPONENT | ACTION | EXPECTED VALUE
:----------:|:----------:|:----------:|:----------:
LoginPage | UserIDTextbox | VerifyValue | "MyUseID"
**Reusable Code, Error Correction and Synchronization:** 測試
開發應用獨立的組件功能,接受特定應用程序的變量數據。一旦組件功能存在,使用框架就能夠在每個被測的應用程序上進行應用。ui
在咱們的設計中,主循環從數據表中讀取記錄,執行一些高層驗證,關注適當的對象,而後使用適當的組件功能,處理完整的表格記錄。組件功能負責肯定什麼動做是被請求的,並基於動做進一步完成表格記錄。
|Framework Pseudo-Code|
|:----------|
|**Primary Record Processor Module:** <br><br>Verify "LoginPage" Exists. (Attempt recovery if not)<br>Set focus to "LoginPage<br>Verify "UserIDTextbox" Exists. (Attempt recovery if not)<br>Find "Type" of component "UserIDTextbox". (It is a Textbox)<br>Call the module that processes ALL Textbox components.<br><br>**Textbox Component Module:**<br><br>Validate the action keyword "VerifyValue".<br>Call the Textbox.VerifyValue function.<br><br>**Textbox.VerifyValue Function:**<br><br>Get the text stored in the "UserIDTextbox" Textbox.<br>Compare the retrieved text to "MyUserID".<br>Record our success or failure.|.net
(未完待續)翻譯