如何选择自动化测试框架

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

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)函数库结构框架(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"

End Sub

最后,最顶层的测试脚本(一级脚本)再去把二级脚本组织和整合在一起执行,例如下面的脚本组合了计算器的标准视图和科学视图的测试脚本:

'Test Script Modularity Framework

'Top level script - represents test case

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 Case OperandOne

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, "ObjectIndex=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 "+"

PushButton Click, "ObjectIndex=8"

Case "-"

PushButton Click, "ObjectIndex=7"

Case "*"

PushButton Click, "ObjectIndex=11"

相关文档
最新文档