Samuele Pilleri
Samuele Pilleri

Reputation: 764

How to exit a test case in UFT

I have many tests that require certain preconditions to be met before continuing and thought I could write a simple function like:

Function FailIfNot(condition, error_message)
    If Not condition Then
        WriteToALM FAILURE, error_message 'convenience function
        ExitScript
    End If
End Function

I've searched online, but can't figure out which Exit* function I should use. Each test case consists of a single action which covers a particular interaction with the application and once developed is run in "batch mode" with all the other test cases by ALM (in development I execute it as a temporary run). Ideally the function should go in a library that is shared with other test scripts, which seems to further complicate it.

Hope I'm not reinventing the wheel here.

Upvotes: 3

Views: 6488

Answers (1)

Corey Snow
Corey Snow

Reputation: 255

I think what you're looking for is 'ExitTest'. Built in function that will exit the running test.

For example I have a EndTest function, and will call it from an if statement. So:

If condition = true
    'do something
Else
    Call EndTest(micFail, "reason", "step")
End If

The EndTest function looks like this:

Function EndTest(strEvent, strReason, strDescription)
    reporter.ReportEvent strEvent, strReason, strDescription
    ExitTest
End Function

Upvotes: 4

Related Questions