Katalon Analytics (beta) – Bringing new insights into test reports. Learn more!

How to use tearDownIfPassed and tearDownIfFailed

Hi

I would like to use the methods tearDownIfFailed and tearDownIfPassed.

when a test completes, I would like to call these methods and check if either of them are true and save that to a variable. If true i would then send a REST call to update a status on another service.

Note: I have checked online documentation and I still do not understand. Please provide a coding example.

Thank you.

 

Comments

  • **This answer is in reference to my question above**

    The code below is what i want to achieve in Katalon studio. This is an example in c#
    [TearDown]
    public void TearDown()
    {
        if (TestContext.CurrentContext.Result.Status == TestStatus.Failed)
        {
            // Your test failed, handle it
        }
    }
  • A sample for you:

    import com.kms.katalon.core.annotation.TearDown
    import com.kms.katalon.core.annotation.TearDownIfFailed
    import com.kms.katalon.core.annotation.TearDownIfPassed

    assert 2 == 1

    @TearDownIfPassed
    def handlePassed() {
    println 'Handle Passed'
    }

    @TearDownIfFailed
    def handleFailure() {
    println 'Handle Failure'
    }

    @TearDown
    def handleTearDown() {
    println 'Handle TearDown'
    }
  • Thank you for answer.
    Can I get information about running browsers  in a method?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!