Michael Kelly在《Choosing a test automation framework》一文中提到测试自动化框架是一组假设、概念和惯例的集合,用于支持自动化测试。(A test automation framework is a t of assumptions, concepts, and practices that provide support for automated software testing.)
Michael Kelly把自动化测试框架划分为5大类:
(1)模块化框架(test script modularity)。
(2)函数库结构框架(test library architecture)。
(3)关键字驱动测试框架(keyword-driven/table-driven testing)。
(4)数据驱动测试框架(data-driven testing)。
(5)混合型框架(hybrid test automation)。
模块化框架(test script modularity)
首先编写底层的三级脚本,例如:
双鱼白羊座配对
Sub Main
Window Set Context, "Caption=Calculator", ""
'5
PushButton Click, "ObjectIndex=10"
'+
PushButton Click, "ObjectIndex=20"
'6
PushButton Click, "ObjectIndex=14"
'=重庆市应急管理局
PushButton Click, "ObjectIndex=21"
'11
Result = LabelUP (CompareProperties, "Text=11.", "UP=Object Properties")
End Sub
Sub Main
Window Set Context, "Caption=Calculator", ""
'20
PushButton Click, "ObjectIndex=11"
PushButton Click, "ObjectIndex=8"
'-
PushButton Click, "ObjectIndex=19"
'10
PushButton Click, "ObjectIndex=7"
PushButton Click, "ObjectIndex=8"
'=
PushButton Click, "ObjectIndex=21"
'10
Result = LabelUP (CompareProperties, "Text=10.", "UP=Object Properties")
End Sub
底层脚本可以作为测试脚本开发任务,分模块下发给每个测试工程师负责开发。然后用一个二级脚本来组织和整合这几个底层的脚本,例如下面是计算器的标准视图下组合底层测试脚本的例子:
'Test Script Modularity Framework
'Script for Standard View
Sub 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 Functionality
CallScript "Test Script Mod Framework - Multiply" GTD时间管理
End Sub
最后,最顶层的测试脚本(一级脚本)再去把二级脚本组织和整合在一起执行,例如下面的脚本组合了计算器的标准视图和科学视图的测试脚本:
'Test Script Modularity Framework
'Top level script - reprents test ca
Sub Main
'Test the Standard View
圆形体积计算公式 CallScript "Test Script Mod Framework - Standard"
'Test the Scientific View
CallScript "Test Script Mod Framework - Scientific"
End Sub
库结构框架(test library architecture)
宫紫把测试脚本做成函数,通过函数之间互相调用来组织测试用例。例如下面的一个函数实现了计算器标准视图的测试:
'Header File
'Test Library Architecture Framework
"Functions Library
Declare Sub StandardViewFunction BasicLib "Functions Library" (OperandOne As Integer, _
'Library Source File
'Test Library Architecture Framework
'Functions Library
Sub StandardViewFunction (OperandOne As Integer, _
OperandTwo As Interger, _
Operation As String)
'Click on first operand
Select Ca OperandOne
Ca 0
PushButton Click, "ObjectIndex=8"
Ca 1
PushButton Click, "ObjectIndex=7"
Ca 2
PushButton Click, "ObjectIndex=11"
Ca 3
PushButton Click, "ObjectIndex=15"
Ca 4
PushButton Click, "ObjectIndex=6"
Ca 5
PushButton Click, "ObjectIndex=10"
Ca 6
PushButton Click, "ObjectIndex=14"
Ca 7
PushButton Click, "ObjectIndex=5"
Ca 8
PushButton Click, "ObjectIndex=9"
Ca 9
PushButton Click, "ObjectIndex=13"
End Select
'Click on cond operand
Select Ca OperandOne
Ca "+"
PushButton Click, "ObjectIndex=8"
Ca "-"
PushButton Click, "ObjectIndex=7"
Ca "*"
PushButton Click, "ObjectIndex=11"
Ca "/"
PushButton Click, "ObjectIndex=15"
End Select
'Click on third operand
Select Ca OperandOne
Ca 0
PushButton Click, "ObjectIndex=8"
Ca 1
PushButton Click, "ObjectIndex=7"
Ca 2
PushButton Click, "ObjectIndex=11"
Ca 3
PushButton Click, "ObjectIndex=15"
Ca 4
木乃伊英文
PushButton Click, "ObjectIndex=6"
Ca 5手工教案
PushButton Click, "ObjectIndex=10"
Ca 6
PushButton Click, "ObjectIndex=14"
Ca 7西芹炒鱿鱼
PushButton Click, "ObjectIndex=5"
Ca 8
PushButton Click, "ObjectIndex=9"
Ca 9
PushButton Click, "ObjectIndex=13"
End Select