Test Complete: Object Driven Test (ODT)
TestComplete 是一款支持自动化脚本设计的测试工具,支持众多框架的测试模式,本文简要介绍一下ODT,及常用的相关脚本命令。
ODT的Tree下面包含两个子节点: Classes 和 Data
可以直接在TC的GUI上面操作,加入相关定义(参见Help手册)。
更灵活,便于维护的是通过脚本定义。
1: 在Classes中定义封装界面的类:
定义类:
ODT.Classes.Declare(classname);
定义类的实例:
ODT.Classes.New(classname);
定义类的特性:
Obj=ODT.Classes.Declare("MyClass"); Obj.AddProperty("name","value");
定义类的方法:
Obj=ODT.Classes.Declare("MyClass");
Obj.AddMethod("methodName","ScriptProc");
// ScriptProc
must be specified in the format
unit_name.routine_name
Both unit_name and routine_name are required.
2: 在Data 中定义相关的数据:
TestObj = ODT["Classes"]["New"]("ClsNotepadTest"); TestObj["ID"] = "ReleaseTest"; FileObj = TestObj["Files"]["AddItemOfClassType"]("ClsFile"); FileObj["Path"] = "C:\\TestFiles\\file1.txt"; OperationObj = FileObj["Operations"]["AddItemOfClassType"]("ClsOperation"); OperationObj["ID"] = "Find"; OperationObj["MenuPath"] = "Edit|Find...";
3:运行测试流程:
Run
method checks each item of this array.
Run
method “processes” this object in the following manner:
Run
method processes this object (i.e. executes its methods and processes the properties) in the described manner. If a property holds an array, the method processes each item of this array in the manner described below. If a property holds an ordinary value, it is ignored.