Forum Discussion

kenm's avatar
kenm
Contributor
8 years ago

Possible to override test step pass/fail via subsequent groovy script?

Good evening all,

 

Is it possible to override the status/result (OK/Failed) of a test step via a subsequent trailing Groovy script?

 

To give the question a little more context.... I want to:

 

    1. Perform async API call

    2. Delay for a few seconds

    3. Verify the results of the async call - which may or may not pass the assertions

    4. Groovy script to check the status of step 3.... if it has FAILED then return to step 2

            This step will also expire after a given number of retries

 

I can get the above to work successfully except the preceeding attempts (where the assertions of step 2 failed) are leading to the test case itself failing. Essentially the last time through it passes fine.

 

I'd like to override/erase the previous failures in step 2 until the last time through.

 

Does that make sense? Thanks for any help!

Ken.

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    If it has to be passed in the first attempt itself, then you do not even consider to repeat the test.

    I believe that you are the better judge as you know if the test is done property as desired though it had failed and finally passed.

    I think you should be ok with it.
    • kenm's avatar
      kenm
      Contributor

      Good morning nmrao,

       

      Sorry I may have not been clear. 

       

      The challenge I have is I have an async call and I want to verify the results of the async call in a subsequent rest call. I have got delays in there that should allow the test to pass but they can be unreliable. So instead I've dropped to a short delay and essentially perform the test step to validate, if it fails it'll jump back to the short delay and retry...

       

      I have this working and once the validate async call step succeeds the test will proceed however it's the fact that some of the earlier retries have failed is leading to the TestCase itself failing, despite the last time through the verify async call step passing...

       

      If that makes sense?

      • krabhishek_30's avatar
        krabhishek_30
        Occasional Contributor

        did you get a solution to this ?

        I am facing a similar problem where i need to explicitly fail a test step based on a condition (which i have in my trailing groovy script).