脚本驱动设计搞的修改版

上次发的基于脚本驱动的自动化测试方案,在这几天的思考之后终于得到了比较满意的方案。在原来的factory模式和bridge模式的基础上又引入了singleton模式。之所以要引入singleton模式的主要原因是问了解决全局数据访问的问题。原先的方案在controlObject级别的对象竟然要跨层次的去访问AppEveriment的数据,这样导致了强耦合。这也是原来方案的最大不足。引入了singleton模式后将读取xml配置文件的工作交给了两个集合:class ControlsCollection 和 class CasesCollection。这两个对象作为全局数据存在提供各个对象对数据的查询操作。在修改方案钟,我有引入了类别属性概念,ControlAttribute  和 StepAttribute这两个基类对象,用于接口的统一访问,这样在使得有新类别加入的时候不用修改已有的接口。
在这次的修改方案中,还有一点比较重要的是我将窗体的管理使用一个单独的类来处理,由于窗体是所有控件的容器所以处理起来比较特殊,因此不便于跟其他控件一起处理,并且窗体的产生都是在操作控件之前的。我将窗体管理类命名为:WinManager 它主要完成如下工作:
    /// <summary>
    /// singleton pattern
    /// this class can do the jobs
    /// 1) Collect the opened window of the application
    /// 2) Remove the all of window of the application
    /// 3) Get the window by FormAttribute
    /// </summary>
并且在这次的修改方案中对整个测试脚本的xml文件格式也进行了比较大的修改,主要是原先的脚本内容和字段命名多比较的含糊。
None.gif <? xml version = " 1.0 "  encoding = " utf-8 " ?>
None.gif
< App >
None.gif  
< ExcludedControls >
None.gif    
< Control id = " MainMenu "   />
None.gif  
</ ExcludedControls >
None.gif  
None.gif  
< Case title = " testWordPadSetting "  savePath = " . " >
None.gif    
< Script driver = " Monad " />
None.gif
None.gif    
< Control id = " View "   action = " click "   owner = " MainMenu " />
None.gif    
< Control id = " Optionsdot.gif "  action = " click "  owner = " MainMenu "   waiter = " Options " />
None.gif
None.gif    
< Control id = " OK "   action = " click "  waiter = " MainForm " />
None.gif
None.gif    
< Control id = " RichEdit "  action = " sendKeys "  value = " Hello World! "   />
None.gif    
< Control id = " RichEdit "  action = " sendKeys "  value = " ^a "    />
None.gif    
< Control id = " FontComboBox "  action = " SelectedIndex "   value = " 16 "  owner = " Formatting " />
None.gif    
None.gif    
< UICapture title = " myScreenShot "  rootControlId = "" />
None.gif    
None.gif  
</ Case >
None.gif
</ App >
这是case文件,
对Controls.xml文件也进行了规范化, 让它只支持三个字段的访问,automationId, className和name
None.gif <? xml version = " 1.0 "  encoding = " utf-8 "   ?>  
None.gif
< Application name = " WordPad.exe " >
None.gif  
< Form refName = " MainForm "   class = "  WordPadClass " >
None.gif    
< Control refName = " Formatting "   id = " 59396 "  controlType = " ToolBar " />
None.gif    
< Control refName = " Standard "  id = " 59392 "  controlType = " ToolBar " />
None.gif    
< Control refName = " RichEdit "   id = " 59648 "  controlType = " Document " />
None.gif    
< Control refName = " MainMenu "   id = " MenuBar "  controlType = " MenuBar "   />
None.gif    
< Control refName = " FontComboBox "  id = " 165 "  controlType = " ComboBox " />
None.gif    
< Control refName = " FontDropDownButton "  id = " DropDown "  controlType  = " Button " />
None.gif    
< Control refName = " FontListBox "   id = " ListBox "  controlType = " List " />
None.gif  
</ Form >
None.gif  
< Form refName = " Options "   class = " #32770 " >
None.gif    
< Control refName = " OK "   id = " 1 "  controlType = " Button " />
None.gif    
< Control refName = " NoWarp "  id = " 1027 "  controlType = " RadioButton " />
None.gif  
</ Form >
None.gif
</ Application >
这样的的设计使得接口更清晰,更具有可维护性和可读性!

转载于:https://www.cnblogs.com/moonz-wu/archive/2007/07/31/838277.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值