User Guide

28 Advanced Concepts
Making a test fail but continue to the end
You may encounter situations where you cannot make the test fail or pass from a script and
still continue to the end. Specifically, this has been reported for tests that change a formula
within a Data Table.
To write a QTP method that causes a test to fail but continue to the end, you create a
keyword, as the following example shows:
Public Function WidthGreaterThan(test_object, minWidth)
actual = test_object.GetROProperty("width")
a = CInt(actual)
b = CInt(minWidth)
If a > b Then
Msg = "WidthGreaterThan", "Width is greater than: " &minWidth
Reporter.ReportEvent micPass, Msg
Else
Msg = "Width " & actual & " is not greater than " & minWidth
Reporter.ReportEvent micFail, "WidthGreaterThan", Msg
End If
End Function
RegisterUserFunc "FlexButton", "WidthGreaterThan", "WidthGreaterThan"
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Products").
FlexButton("Remove from cart_11").WidthGreaterThan 10
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Products").
FlexButton("Remove from cart_11").WidthGreaterThan 1099
Browser("FlexStore").FlexApplication("flexstore").FlexCanvas("Products").
FlexButton("Remove from cart_11").WidthGreaterThan 100