QTP CheckPoint設置

檢查點、驗證點方法------CheckProperty方法

    object.CheckProperty(PropertyName, PropertyValue, [TimeOut])

-------------------------------------------------------------------------------------------------

PropertyName:要檢查的屬性名
PropertyValue:預期結果值(如果最後檢查完畢,發現不符合預期值,則會返回False,並引入QTP測試報告;反之,則返回True,並在測試報告中以Passed顯示)
TimeOut:等待時間,單位毫秒

檢查點例子:

Set oBrowser=Description.Create()
oBrowser("micClass").value="Browser"

Set oPage=Description.Create()
oPage("micClass").value="Page"

Set oWebEdit=Description.Create()
oWebEdit("name").value="wd"

Browser(oBrowser).Page(oPage).WebEdit(oWebEdit).Set "12306"
Browser(oBrowser).Page(oPage).WebEdit(oWebEdit).CheckProperty "value","12306"

Set oBrowser=Nothing
Set oPage=Nothing
Set oWebEdit=Nothing

自定義檢查點------ReportEvent

    Reporter函數有3個屬性(Filter,ReportPath,RunStatus)和2個方法(ReportEvent,ReportNote),自定義檢查點是針對Reporter函數的ReportEvent方法來說的

Description

Reports an event to the run results.

Syntax

Reporter.ReportEvent EventStatusReportStepNameDetails [, ImageFilePath]

    EventStatus,測試結果的狀態,有4種狀態

  1. micPass: 對應數字0
  2. micFail: 對應數字1
  3. micDone: 對應數字2
  4. micWarning: 對應數字3

    ReportStepName,在測試報告中顯示的測試名字
    Details,在測試報告中顯示的測試描述
    ImageFilePath,不是必填項,將截圖插入到報告中

自定義檢查點例子:

Set oBrowser=Description.Create()
oBrowser("micClass").value="Browser"

Set oPage=Description.Create()
oPage("micClass").value="Page"

Set oWebEdit=Description.Create()
oWebEdit("name").value="wd"

Dim ActualValue
Dim ExpectedValue
ExpectedValue="12306"
Browser(oBrowser).Page(oPage).WebEdit(oWebEdit).Set ExpectedValue
ActualValue=Browser(oBrowser).Page(oPage).WebEdit(oWebEdit).GetROProperty("value")

'If ActualValue=ExpectedValue Then
'Reporter.ReportEvent micPass,"文本框輸入測試","百度首頁文本框輸入測試"
'Reporter.ReportNote "This test was run from Lemon_s."
'else
'Reporter.ReportEvent micFail,"文本框輸入測試","百度首頁文本框輸入測試"
'End If

If ActualValue=ExpectedValue Then
i=0
else
i=1
End If

Reporter.ReportEvent i,"文本框輸入測試","百度首頁文本框輸入測試"
Reporter.ReportNote "This test was run from Lemon_s."

Set oBrowser=Nothing
Set oPage=Nothing
Set oWebEdit=Nothing

自定義檢查點和CheckProperty區別:

  1. CheckProperty使用到的ReportEvent只有2種,Pass和Fail,而自定義檢查點有4種
  2. CheckProperty只能檢查控件的屬性,自定義檢查點可以檢查各種各樣的代碼邏輯,從多角度去驗證自動化測試
  3. CheckProperty的StepName和Details由系統自動生成,自定義檢查點可以自由鍵入
  4. CheckProperty沒有講截圖插入在測試報告中的功能,自定義檢查點有

自定義檢查點狀態和測試結果的關係

  1. 在一個測試中,只要有一個Fail,整個測試的結果就是Fail
  2. 如果沒有Fail,只要有一個Warning,這個測試的結果就是Warning
  3. 全部是Pass,整個測試結果才Pass
  4. Done不影響這個測試的結果
發佈了28 篇原創文章 · 獲贊 5 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章