winningchen 发表于 2017-12-27 11:33:14

功能测试中自动化测试框架的分析和应用03-数据池、对象库

本帖最后由 winningchen 于 2017-12-27 13:01 编辑

数据池用于存储测试数据,实现测试数据和测试脚本的分离,测试数据的改变不会影响测试脚本。根据需要设计数据池的字段,另外数据池也可被多个测试用例共享。下图所示的是用户登录这一功能的数据池,在这一个数据池中有三个字段:testCase表示测试用例名称,account表示登录帐号,passWord表示登录使用的密码。下面用实际测试对象为主站软件,在主界面进行用户登录的数据池:



举例说明,用户登录的自动化测试的测试用例描述表:
具体测试用例




对象库
对象库包含了对象和其相关的测试步骤。利用对象库把和测试步骤封装起来,实现了测试脚本和的分离,可以有效解决的经常变化对测试脚本的影响。目前改变了,直接修改对象库中相对应的即可,测试脚本不需做任何改动。
调用对象库方法:
验证点方法:
脚本流程包括:
调用基础业务逻辑库进行满足前提条件的操作—调用数据池—调用对象库方法—验证点方法--调用基础业务逻辑库自动写入验证结果。






Alawn 发表于 2017-12-28 12:50:40

学习了。。

winningchen 发表于 2017-12-29 17:01:54

//要确定一个界面元素主要的参数有以下几个:ControlName、Localized、ControlTypeName、AutomationId

//自动化元素的类定义

private ControlType controlType;

      private string name;

      private string localizedControlType;

      private string automationId;



      public ElementDefine(ControlType conType, string name, string LCtype, string automationId)

      {

            this.controlType = conType;

            this.name = name;

            this.localizedControlType = LCtype;

            this.automationId = automationId;

      }

      public ControlType ControlType { get { return controlType; } set { } }

      public string Name { get { return name; } set { } }

      public string LocalizedControlType { get { return localizedControlType; } set { } }

      public string AutomationId { get { return automationId; } set { }



//根据对象属性返回对象的方法

Public AutomationElement GetElementByDescendants(AutomationElement parentWindowHandle){…}

//根据controlPattern定义的方法

public bool ElementInvoke(AutomationElement ipe)//invoke pattern element

public bool ElementValuePattern(AutomationElement vpe, string value)//value pattern element

public bool ElementTextPattern(AutomationElement tpe, string value)//text pattern element



}



//UI界面元素对象初始化:

ElementDefine loginElement = new ElementDefine(ControlType.Button, "用户登录", "按钮",””);//构造函数中对元素的参数进行初始化
页: [1]
查看完整版本: 功能测试中自动化测试框架的分析和应用03-数据池、对象库