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"
in ca '=
诧异 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 Viewtry歌词翻译
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"
三年级下册英语试卷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"
thruster
学习方法总结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