cancel
Showing results for 
Search instead for 
Did you mean: 

how to loop a test request to rerun when failed at previous attempt

New Contributor

how to loop a test request to rerun when failed at previous attempt

I have a REST GET request step( Step 1) where on first attempt it gives null response and on rerunning the same test again with same test conditions (Step 1)gives the valid response. I have a follow up request (Step 2) which refers to Step 1 response and it fails as Step 1 failed.

In this condition, what steps can be added to get the valid response from Step 1 from next few attempts.

Is there a way to loop or rerun a particular step on failures and then transfer the valid response values from Step 1 to Step 2.

 

4 REPLIES 4
Frequent Contributor

Re: how to loop a test request to rerun when failed at previous attempt

Ok,

 if i understand your question correctly, i think in your scenario i would rather make a clone of the first request and include that as step 3 and have different assertions for step 3 where it expects to get some response. that way you don't have to loop it, right?

New Contributor

Re: how to loop a test request to rerun when failed at previous attempt

Thank you for your response. I tried cloning and it doesn't work. I got the test step working by writing a groovy step with if else condition and called the same step repeatedly if failed at first attempt otherwise it will go to next step. Thanks!

Visitor

Re: how to loop a test request to rerun when failed at previous attempt

 Can you share your groovy script?

Community Hero

Re: how to loop a test request to rerun when failed at previous attempt

Hey @anushar17


Yeah, id be interested to see the script for this too please!

Ta

Richie
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta