<ruby id="h6500"><table id="h6500"></table></ruby>
    1. <ruby id="h6500"><video id="h6500"></video></ruby>
          1. <progress id="h6500"><u id="h6500"><form id="h6500"></form></u></progress>
            • 軟件測試技術(shù)
            • 軟件測試博客
            • 軟件測試視頻
            • 開(kāi)源軟件測試技術(shù)
            • 軟件測試論壇
            • 軟件測試沙龍
            • 軟件測試資料下載
            • 軟件測試雜志
            • 軟件測試人才招聘
              暫時(shí)沒(méi)有公告

            字號: | 推薦給好友 上一篇 | 下一篇

            軟件測試工具QTP面向對象的框架

            發(fā)布: 2010-9-08 09:48 | 作者: 網(wǎng)絡(luò )轉載 | 來(lái)源: 領(lǐng)測軟件測試網(wǎng)采編 | 查看: 166次 | 進(jìn)入軟件測試論壇討論

            領(lǐng)測軟件測試網(wǎng)

            軟件測試工具QTP面向對象的框架

            這種框架的核心思想是把某個(gè)窗口的測試對象和相關(guān)業(yè)務(wù)核心操作都封裝在VBS的類(lèi)中,稱(chēng)之為GUI層,或者叫GUI-業(yè)務(wù)橋接層。例如下面的登錄界面類(lèi):

              ' 登錄界面類(lèi),封裝了界面對象數據以及相關(guān)業(yè)務(wù)操作

              Class Login

              Private m_htChildObjects 'As Scripting.Dictionary

              Public Property Get ChildObjects()

              Set ChildObjects = m_htChildObjects

              End Property

              Public Property Let ChildObjects(ByRef dic)

              Set m_htChildObjects = dic

              End Property

              ' 初始化界面對象并驗證對象是否存在

              Public Function Init()

              ChildObjects = CreateObject("Scripting.Dictionary")

              With ChildObjects

              .Add "LoginDialog", Dialog("text:=Login")

              .Add "AgentName", ChildObjects.Item("LoginDialog").WinEdit("attached text:=Agent Name:")

              .Add "Password", ChildObjects.Item("LoginDialog").WinEdit("attached text:=Password:")

              .Add "Submit", ChildObjects.Item("LoginDialog").WinButton("text:=OK")

              End With

              'IsContextLoaded is a function that iterates through the Dictionary and checks if the GUI objects "exist"

              Init = IsContextLoaded(ChildObjects) ' 檢查界面層對象是否存在

              End Function

              ' 與界面對象綁定的各類(lèi)業(yè)務(wù)操作

              ' 測試數據從GlobalDictionary中獲取(放在Data層),這里把測試數據做成函數參數可能會(huì )更好?!

              Public Function SetUsername()

              ChildObjects.Item("AgentName").Set GlobalDictionary.Item("AgentName")

              End Function

              Public Function SetPassword()

              ChildObjects.Item("Password").Set GlobalDictionary.Item("Password")

              End Function

              Public Function Submit()

              ChildObjects.Item("Submit").Click

              End Function

              End Class

              Public Function CreateLogin()

              Dim objLogin

              Set objLogin = New Login

              Set CreateLogin = objLogin

              End Function

              在業(yè)務(wù)層的類(lèi)中封裝業(yè)務(wù)操作流程的代碼,例如下面的登錄流程:

              ' 登錄業(yè)務(wù)類(lèi),封裝了登錄過(guò)程的業(yè)務(wù)操作流程

              Class do_login

              Public Default Function Run()

              Dim intStatus

              Set objLogin = CreateLogin() ' 調用GUI層的Login類(lèi)

              If objLogin.Init() Then ' 如果所需的界面對象都存在,則執行業(yè)務(wù)操作流程

              objLogin.SetUsername()

              objLogin.SetPassword()

              objLogin.Submit()

              intStatus = micPass 'If login succeeds

              Else

              intStatus = micFail

              End If

              Run = intStatus

              End Function

              End Class

              Public Function Create_do_login()

              Dim bzLogin

              Set bzLogin = New do_login

              Set Create_do_login = bzLogin

              End Function

              這種寫(xiě)法的好處,除了可以細粒度地抽象、分解業(yè)務(wù)的測試代碼,提高可重用性外,還可以在業(yè)務(wù)層的代碼執行前,先讓界面層檢查驗證所需的測試對象是否都存在( 例如上面代碼中的objLogin.Init() ),避免了QTP在運行過(guò)程中碰到對象不存在的時(shí)候卡住的現象。

              在界面層的Init方法中,通過(guò)描述性編程把測試對象都存入Dictionary中,然后用IsContextLoaded方法遍歷對象,檢查是否在運行時(shí)都存在:

              ' 檢查界面層對象是否存在并寫(xiě)入測試報告

              Public Function IsContextLoaded(ByRef htContext)

              Dim ix, items, keys, strDetails, strAdditionalRemarks

              IsContextLoaded=true

              items = htContext.Items

              keys = htContext.Keys

              For ix = 0 To htContext.Count-1

              IsContextLoaded = IsContextLoaded And items(ix).Exist(0)

              strDetails = strDetails & vbNewLine & "Object #" & ix+1 & ": '" & keys(ix) & "' was"

              If IsContextLoaded Then

              intStatus = micPass

              strDetails = strDetails & ""

              strAdditionalRemarks = ""

              Else

              intStatus = micWarning

              strDetails = strDetails & " not"

              strAdditionalRemarks = " Please check the object properties."

              End If

              strDetails = strDetails & " found." & strAdditionalRemarks

              Next

              Reporter.ReportEvent intStatus, "IsContextLoaded", strDetails

              End Function

            延伸閱讀

            文章來(lái)源于領(lǐng)測軟件測試網(wǎng) http://kjueaiud.com/

            TAG: qtp QTP 工具 框架 面向對象 軟件測試


            關(guān)于領(lǐng)測軟件測試網(wǎng) | 領(lǐng)測軟件測試網(wǎng)合作伙伴 | 廣告服務(wù) | 投稿指南 | 聯(lián)系我們 | 網(wǎng)站地圖 | 友情鏈接
            版權所有(C) 2003-2010 TestAge(領(lǐng)測軟件測試網(wǎng))|領(lǐng)測國際科技(北京)有限公司|軟件測試工程師培訓網(wǎng) All Rights Reserved
            北京市海淀區中關(guān)村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
            技術(shù)支持和業(yè)務(wù)聯(lián)系:info@testage.com.cn 電話(huà):010-51297073

            軟件測試 | 領(lǐng)測國際ISTQBISTQB官網(wǎng)TMMiTMMi認證國際軟件測試工程師認證領(lǐng)測軟件測試網(wǎng)

            老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月
              <ruby id="h6500"><table id="h6500"></table></ruby>
              1. <ruby id="h6500"><video id="h6500"></video></ruby>
                    1. <progress id="h6500"><u id="h6500"><form id="h6500"></form></u></progress>