记录
想自动化任何一个仅在一个地点记录但在不同地点(如日本、中国、法国)回放的全球化应用程序,请遵循以下步骤:
在 ivory.properties 文件中设置 Enable Localization 变量为 True (rational.test.ft.services.enable_localization=true) ,这个变量在 Rational Functional Tester 的安装位置能够找到。(参见列表1的源代码。)
列表1. ivory.properties 文件的一部分,其中 Enable Localization 变量被设为 True
###
### Internal properties: Not intended for consumer modification
###
# Version number applied to the enabler.wsw plugin when an eclipse shell gets enabled
rational.test.ft.enabler.plugin.version=7.0.0
# rational client JVM startup options
#rational.test.ft.client.jvm_options=-xj9
# When enabled this option allows the install directory for the local
# TestContext to differ from the global setting
# (the install directory of the first TestContext created)
rational.test.ft.install_dir.ignore_mismatch=true
# When enabled this option allows recording / playback against product own UI
rational.test.ft.testability.allow_testing=true
# When enabled this property allows string lookup in the localized
# string table, if available
rational.test.ft.services.enable_localization=true
# Internal. Allow connecting to a .NET project for execution framework testing
#rational.test.ft.testability.allow_vbnet_remote=true
第2步 使用 IBM® 框架(以前被称为 ITCL)在 Rational Functional Tester 中开发测试脚本。使用这个框架确保了结构化的方法去开发测试脚本,并且提供了其他好处:通过组织测试自动化脚本形成 AppObjects、任务、测试用例层来实现对于测试自动化脚本的一层抽象。最小化的复杂度,以及可复用的且一般化的测试脚本。一个提供了一般自动化功能的库文件的基本集,用于测试脚本开发和扩展。
使用 IBM 框架组织为 JFC 按钮全球化应用程序而开发的 Rational Functional Tester 脚本,使它们分为 3 层(参见图5):
appObjects 层: 新建一个叫做appJbutton的类,这个类存储与测试脚本交互的对象。
任务层: 新建一个叫做 taskJbutton 的类,其中真正的逻辑以各种任务的形式写成,也叫做函数。
测试用例层:新建一个叫做 testCaseJbutton的 类,其中写在任务层的各种任务用来实现端到端的测试场景。
图5. 使用 IBM 框架组织 Rational Functional Tester 脚本
使用 Rational Functional Tester 记录任何地点(如英国)的脚本。
识别因不同地点值有变化的所有对象属性。
现在打开对象定义文件, 在 Rational Functional Tester 里也叫做对象图 。
选择因地点不同志也有所变化的对象属性。在这个应用程序范例中,javax.swing.Jbutton 对象的 accessibleName 和 name 属性有变化(参见图 6)。
图6. 全球化应用程序的对象图,具有变化值的对象属性被选中