版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、Michael Kelly在Choosing a test automation framework一文中提到測試自動化框架是一組假設、概念和慣例的集合,用于支持自動化測試。(A test automation framework is a set of assumptions, concepts, and practices that provide support for automated software testing.)Michael Kelly把自動化測試框架劃分為5大類:(1)模塊化框架(test script modularity)。(2)函數(shù)庫結構框架(test libra
2、ry architecture)。(3)關鍵字驅動測試框架(keyword-driven/table-driven testing)。(4)數(shù)據驅動測試框架(data-driven testing)。(5)混合型框架(hybrid test automation)。模塊化框架(test script modularity)首先編寫底層的三級腳本,例如:Sub Main Window Set Context, "Caption=Calculator", "" '5 PushButton Click, "ObjectIndex=10&quo
3、t; '+ PushButton Click, "ObjectIndex=20" '6 PushButton Click, "ObjectIndex=14" '= PushButton Click, "ObjectIndex=21" '11 Result = LabelUP (CompareProperties, "Text=11.", "UP=Object Properties") End SubSub Main Window Set Context, &quo
4、t;Caption=Calculator", "" '20 PushButton Click, "ObjectIndex=11" PushButton Click, "ObjectIndex=8" '- PushButton Click, "ObjectIndex=19" '10 PushButton Click, "ObjectIndex=7" PushButton Click, "ObjectIndex=8" '= PushBut
5、ton Click, "ObjectIndex=21" '10 Result = LabelUP (CompareProperties, "Text=10.", "UP=Object Properties") End Sub底層腳本可以作為測試腳本開發(fā)任務,分模塊下發(fā)給每個測試工程師負責開發(fā)。然后用一個二級腳本來組織和整合這幾個底層的腳本,例如下面是計算器的標準視圖下組合底層測試腳本的例子:'Test Script Modularity Framework'Script for Standard ViewSub
6、 Main 'Test Add Functionality CallScript "Test Script Mod Framework - Add" 'Test Subtract Functionality CallScript "Test Script Mod Framework - Substract" 'Test Divide Functionality CallScript "Test Script Mod Framework - Divide" 'Test Multiply Functiona
7、lity CallScript "Test Script Mod Framework - Multiply" End Sub最后,最頂層的測試腳本(一級腳本)再去把二級腳本組織和整合在一起執(zhí)行,例如下面的腳本組合了計算器的標準視圖和科學視圖的測試腳本:'Test Script Modularity Framework'Top level script - represents test caseSub Main 'Test the Standard View CallScript "Test Script Mod Framework - S
8、tandard" 'Test the Scientific View CallScript "Test Script Mod Framework - Scientific" End Sub庫結構框架(test library architecture)把測試腳本做成函數(shù),通過函數(shù)之間互相調用來組織測試用例。例如下面的一個函數(shù)實現(xiàn)了計算器標準視圖的測試:'Header File'Test Library Architecture Framework"Functions LibraryDeclare Sub StandardViewF
9、unction BasicLib "Functions Library" (OperandOne As Integer, _'Library Source File'Test Library Architecture Framework'Functions LibrarySub StandardViewFunction (OperandOne As Integer, _ OperandTwo As Interger, _ Operation As String) 'Click on first operand Select Case Oper
10、andOne Case 0 PushButton Click, "ObjectIndex=8"Case 1 PushButton Click, "ObjectIndex=7"Case 2 PushButton Click, "ObjectIndex=11"Case 3 PushButton Click, "ObjectIndex=15"Case 4 PushButton Click, "ObjectIndex=6"Case 5 PushButton Click, "ObjectInde
11、x=10"Case 6 PushButton Click, "ObjectIndex=14"Case 7 PushButton Click, "ObjectIndex=5"Case 8 PushButton Click, "ObjectIndex=9"Case 9 PushButton Click, "ObjectIndex=13"End Select 'Click on second operand Select Case OperandOne Case "+" PushBu
12、tton Click, "ObjectIndex=8"Case "-" PushButton Click, "ObjectIndex=7"Case "*" PushButton Click, "ObjectIndex=11"Case "/" PushButton Click, "ObjectIndex=15"End Select 'Click on third operand Select Case OperandOne Case 0 PushBu
13、tton Click, "ObjectIndex=8"Case 1 PushButton Click, "ObjectIndex=7"Case 2 PushButton Click, "ObjectIndex=11"Case 3 PushButton Click, "ObjectIndex=15"Case 4 PushButton Click, "ObjectIndex=6"Case 5 PushButton Click, "ObjectIndex=10"Case 6 Pus
14、hButton Click, "ObjectIndex=14"Case 7 PushButton Click, "ObjectIndex=5"Case 8 PushButton Click, "ObjectIndex=9"Case 9 PushButton Click, "ObjectIndex=13"End Select'=PushButton Click, "ObjectIndex=21"End Sub然后再用另外一個腳本來調用上面的函數(shù),通過傳入不同的參數(shù)來指定測試不同的內容:
15、39;Test Library Architecture Framework'Test Case script'$Include "Functions Library.sbh"Sub Main 'Test the Standard View Window Set Context, "Caption=Calculator", "" 'Test Add Functionalty StandardViewFunction 3,4,"+" Result = LabelVP (CompareP
16、roperties, "Text=7.", "VP=Add") 'Test Subtract Functionalty StandardViewFunction 3,2,"-" Result = LabelVP (CompareProperties, "Text=1.", "VP=Sub") 'Test Multiply Functionalty StandardViewFunction 4,2,"*" Result = LabelVP (ComparePro
17、perties, "Text=8.", "VP=Mult") 'Test Divide Functionalty StandardViewFunction 10,5,"/" Result = LabelVP (CompareProperties, "Text=2.", "VP=Div") End Sub關鍵字驅動框架(keyword-driven/table-driven testing)首先定義關鍵字表格,關鍵字表格一般存儲在測試數(shù)據庫、Excel或文件中。例如下面的表格定義了測試Wi
18、ndows計算器所需要的所有對象、操作、測試數(shù)據:WindowControlActionArgumentsCalculatorMenuView, StandardCalculatorPushbuttonClick1CalculatorPushbuttonClick+CalculatorPushbuttonClick3CalculatorPushbuttonClick=CalculatorVerify Result4CalculatorClearCalculatorPushbuttonClick6CalculatorPushbuttonClick-CalculatorPushbuttonClic
19、k3CalculatorPushbuttonClick=CalculatorVerify Result3然后編寫驅動代碼,讀取上述表格,分析出測試對象、測試操作、測試數(shù)據,編寫高度抽象的測試邏輯,下面是一個框架的偽代碼:Main Script / Program Connect to data tables. Read in row and parse out values. Pass values to appropriate functions. Close connection to data tables. Menu Module Set focus to window. Select
20、 the menu pad option. Return. Pushbutton Module Set focus to window. Push the button based on argument. Return. Verify Result Module Set focus to window. Get contents from label. Compare contents with argument value. Log results. Return.有了驅動框架后,只需要按一定的格式編輯表格的數(shù)據,就可以利用驅動框架遍歷表格中的每一行數(shù)據,執(zhí)行所有測試用例。數(shù)據驅動框架(D
21、ata-Driven Testing)數(shù)據驅動框架與關鍵字驅動框架類似,測試數(shù)據都存儲在數(shù)據庫或Excel文件,但是數(shù)據驅動框架的測試用例、測試步驟和測試邏輯是在測試腳本中編寫的,而不像關鍵字驅動框架一樣放在表格中。例如對于圖中的測試,可以把每個輸入框的數(shù)據進行參數(shù)化,在Excel文件中存儲(如果是使用Rational Robot的話就可以直接使用DataPool)。如果通過錄制產生腳本的話,可得到腳本如下所示:'Data Driven Framework'Test Case ScriptSub Main 'Make An Order Window Set Contex
22、t, "Name=frmOrder", "" 'Card Number EditBox Click, "Name=txtCreditCard", "Coords=16,9" InputKeys "3333444455556666" 'Expiration Date EditBox Click, "Name=txtExpirationDate", "Coords=6,7" InputKeys "3333444455556666&qu
23、ot; 'Place Order PushButton Click, "Name=cmdOrder" 'Confirmation Screen Window SetContext, "Name=frmConfirm", "" PushButton Click, "Name=cmdOK" End Sub我們可以在表格中填寫參數(shù)對應的測試數(shù)據:然后在修改腳本如下:'Data Driven Framework'Test Case Script'$Include "SQAU
24、TIL.SBH"Sub Main Dim Result As Integer Dim DatapoolHandle As Long Dim DatapoolReturnValue As Variant 'Open the datapool DatapoolHandle = SQADatapoolOpen("OrderFormDP") '.Add error checking. 'Loop through the datapool While SQADatapoolFetch(DatapoolHandle) = dqaDpSuccess
25、39;Open Order Form Window SetContext, "Name=frmMain", "" PushButton Click, "Name=cmdOrder" Window SetContext, "Name=frmOrder", "" 'Card Number Result = SQADatapoolValue(DatapoolHanle, "Credit Card Number", DatapoolReturnValue) ".Add error checking. EditBox Click, "Name=txtCreditCard", "Coords=16,9" '.Clear Value. InputKeys DatapoolReturnValue 'Expiration Date Result = SQADatapoolValue(DatapoolHandle, "
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年環(huán)境友好型清潔生產技術服務合同
- 2024年陽光房裝修合同模板
- 人防門安裝工程施工合同
- 工程項目分包商合同書
- 二手機械設備買賣協(xié)議范本
- 權威學校聯(lián)合辦學協(xié)議書
- 裝修材料購買合同2024年
- 夫妻協(xié)議書常見問題解答
- 學生安全管理協(xié)議
- 人事派遣代理協(xié)議
- 小學美術人美五年級下冊多彩的民族傳統(tǒng)紋樣敦煌藻井紋樣教案
- 2023屆衡南縣“五科聯(lián)考”數(shù)學試卷(含答案)
- 公司稅務管理辦法
- 競賽培訓專題6-整數(shù)的整除性
- 武術操《英雄少年》全套動作教學教案
- 2022年部編四年級語文上冊專項選擇正確讀音
- 綠化養(yǎng)護重點難點分析及解決措施
- 2022中央機關遴選公務員筆試題
- 安全生產費用提取 和使用管理制度(3篇)
- 《眼科學基礎》期末復習題庫含答案
- 西師版數(shù)學一年級上冊一、二單元測試題參考范本
評論
0/150
提交評論