
自动化测试脚本设计与框架设计【tib自动化测试工作室】.pdf
37页自动化测试脚本设计与框架设计自动化测试脚本设计与框架设计www.AutomationQA.com框架的定义框架的定义• Michael Kelly: A test automation framework is a set of assumptions, concepts, and practices that provide support for automated software testing. • Wikipedia: A Test Automation Framework is a set of assumptions, concepts and tools that provide support for automated software testing. The main advantage of such a framework is the low cost for maintenance. If there is change to any test case then only the test case file needs to be updated and the Driver Script and Startup script will remain the same. There's no need to update the scripts in case of changes to the application.• AutomatedTestingI: a set of abstract concepts, processes, procedures and environment in which automated tests will be designed, created and implemented. In addition, this framework definition includes the physical structures used for test creation and implementation, as well as the logical interactions among those components. • 框架是一组自动化测试的规范、测试脚 本的基础代码,以及测试思想、惯例的 集合。
可用于减少冗余代码、提高代码 生产率、提高代码重用性和可维护性框架的发展历史框架的发展历史框架的种类框架的种类• 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)框架的框架的ROI线性框架的缺陷线性框架的缺陷• 录制回放 • 脚本形式模块化、函数库结构模块化、函数库结构• QTP – Test – Action – Sub、Function • TestComplete – ProjectSuite、Project – Unit – Sub、FunctionActions VS. Functions• Action的优缺点 • Function的优缺点 • 动手实践项目结构项目结构脚本层次结构脚本层次结构面向对象思想在自动化脚本设计 中的体现面向对象思想在自动化脚本设计 中的体现• 脚本的分层思想 • 封装 • 复用 • 需要用到类吗?Main – Sub 结构化框架结构化框架数据驱动数据驱动• 数据源设计 – 文件 – Excel – ADO • 驱动脚本多语言版本的测试多语言版本的测试• 测试对象的数据 • 测试数据数据管理数据管理• 数据存在脚本中 • 数据存在DataTable • 数据存在Excel • 数据存在XML • 数据存在DB调度执行管理调度执行管理• suiteControl、LoadAndRunAction• AOM • Test Batch Runner、MTM • QTRunner场景恢复场景恢复• 状态恢复 • 数据恢复 • 脚本异常处理基于基于Excel的用例组织框架的用例组织框架(1)Test SetTestCaseTest DataTest Data基于基于Excel的用例组织框架的用例组织框架(2)业务流程测试业务流程测试(BPT)• QC+QTP • 业务组件、Test Resources • Test Plan • Test LabSAFFRON基于基于SAFFRON的扩展框架的扩展框架面向对象关键字框架面向对象关键字框架Demo.vbs: BrowserTo(“$Url“) SetShareStep(“setState.vbs“)setState.vbs: obj(“Name“).set “$setValue“ obj(“Search“).Click基于基于DataTable的关键字框架的关键字框架Framework Manager测试对象管理测试对象管理• 对象存储在QTP的OR文件 • 对象存储在Excel • 对象存储在XML • 对象存储在DB测试对象处理框架测试对象处理框架• Add-in Extensibility• QTestWare自动化测试日志 与 报告自动化测试日志 与 报告• ReporterManager • 把测试报告写入Excel • 把测试报告写入HTML页面广义框架广义框架 – 脚本规范脚本规范• 文件命名 • 常量、变量命名 • 对象命名 • 注释 • 代码风格 • …欢迎课后交流欢迎课后交流• 陈能技 • Email: testing_is_believing@ • : 1837632674《QTP自动化测试进阶》 《软件自动化测试成功之道》TIB自动化测试工作室 自动化测试资讯平台 。












