<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)有公告

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

            SilkTest天龍八部系列1-初始化和構造函數

            發(fā)布: 2011-3-31 09:46 | 作者: 不詳 | 來(lái)源: 領(lǐng)測軟件測試網(wǎng)采編 | 查看: 22次 | 進(jìn)入軟件測試論壇討論

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

              SilkTest天龍八部系列1-初始化和構造函數  軟件測試

              SilkTest沒(méi)有提供專(zhuān)門(mén)的構造函數機制,但是在類(lèi)對象生成的過(guò)程中,會(huì )先初始化在類(lèi)中申明的變量。我們可以在初始化該變量的時(shí),

              調用某些函數完成對象初始化工作,看上去好像是調用了構造函數一樣。不過(guò)要記住的是,這只是用來(lái)模擬構造函數而已。

              下面是一個(gè)例子:view plaincopy to clipboardprint?01.[-] winclass myClass 02. [ ] boolean bConstructed = Constructor (SubStr (WindowTag(this), 2)) 03. [ ] string sSetMe 04. [ ] integer i 05. [ ] 06. [-] boolean Constructor (string sConstructorData) 07. [-] if (!IsSet(bConstructed)) 08. [ ] sSetMe = sConstructorData 09. [ ] return true 10. [ ] 11. [-] property SetMe 12. [-] string Get() 13. [ ] return sSetMe 14.[ ] 15.[ ] // test that the myClass constructor works 16.[-] testcase testClass () appstate none 17. [ ] window myObject = myClass ("Set property") 18. [ ] print(WindowTag(myObject)) 19. [ ] print ("myObject.SetMe = {myObject.SetMe}") 20. [ ] print ("myObject.i = {myObject.i}") [-] winclass myClass

              [ ] boolean bConstructed = Constructor (SubStr (WindowTag(this), 2))

              [ ] string sSetMe

              [ ] integer i

              [ ]

              [-] boolean Constructor (string sConstructorData)

              [-] if (!IsSet(bConstructed))

              [ ] sSetMe = sConstructorData

              [ ] return true

              [ ]

              [-] property SetMe

              [-] string Get()

              [ ] return sSetMe

              [ ]

              [ ] // test that the myClass constructor works

              [-] testcase testClass () appstate none

              [ ] window myObject = myClass ("Set property")

              [ ] print(WindowTag(myObject))

              [ ] print ("myObject.SetMe = {myObject.SetMe}")

              [ ] print ("myObject.i = {myObject.i}")

              我們來(lái)分析一下這段代碼。

              一開(kāi)始聲明了一個(gè)myClass類(lèi),他有三個(gè)變量,其中bConstructed的初始化調用了類(lèi)的一個(gè)成員函數Constructor(),這個(gè)函數其實(shí)

              可以叫任何名字。所以,window myObject = myClass ("Set property")這句直接會(huì )導致

              成員函數Constructor()被調用。那么,為什么要給該函數傳一個(gè)參數SubStr (WindowTag(this), 2)進(jìn)去呢,這需要了解一下

              WindowTag()的意義,WindowTag()會(huì )返回對象的tag,而不管該對象是否存在。一般的Tag都是以斜線(xiàn)/開(kāi)頭的,

              window myObject = myClass ("Set property")這句的意思你就可以理解為(其實(shí)這不太容易理解,沒(méi)辦法,4Test當初就是這么設計的)

              獲取對象"Set property"的Tag,它的Tag就是"/Set property"。所以在初始化bConstructed的過(guò)程中,同時(shí)初始化了成員變量

              bConstructed,而成員變量i并沒(méi)有被初始化,所以當你運行整個(gè)腳本的時(shí)候,會(huì )得到如下的輸出:

              view plaincopy to clipboardprint?01.[-] Testcase testClass - 1 error 02. [ ] /Set property 03. [ ] myObject.SetMe = Set property 04. [ ] *** Error: Variable (i) has not been set 05. [ ] Occurred in testClass at test3.t(20)

            延伸閱讀

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

            TAG: 天龍八部


            關(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>