TestComplete--Object Driven Test

                              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:运行测试流程:

  • If a tree node (data group, variable, object, array, etc). holds an ordinary value (string, integer, etc.), no action is performed and the method goes to the next tree node of the same level.
  • If a tree node holds an array, the Run method checks each item of this array.
    • If an item holds an ordinary value, no action is performed and the method goes to the next item.
    • If an item holds an object, the method processes this object in the manner described below.
    • If an item holds an array, the method processes each item of this array in the same way it processes the variable’s array.
  • If a tree node holds an object, the Run method “processes” this object in the following manner:
    • Executes all object methods that are specified as Init . These methods are executed in order of appearance in the editor. You can change the order using the editor's context menu items. See How to Create, Modify and Delete Methods .
    • Analyzes the object properties. If a property holds an object, the 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.
    • Calls non-Init methods (the methods are called in order of appearance in the editor. For information, on how to change the method position, see How to Create, Modify and Delete Methods ).

猜你喜欢

转载自wzy1986714.iteye.com/blog/935927