Ask a Question

How to Retry a Test Case or Test Step (ReadyAPI)

Rememo
Contributor

How to Retry a Test Case or Test Step (ReadyAPI)

If one particular test step fails, how do I retry or rerun either that specific Test Step or even the whole Test Case again?

6 REPLIES 6
richie
Community Hero

Hi @Rememo,

I must be misunderstanding but you can re-execute a failed step, testcase, or testsuite by selecting the green arrow (execute) button.

Can you clarify your point please?

Ta

Rich
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

Hey Richie,

 

So sometimes a test step fails intermittently within my Test Case and I want an automate re-run/retry the whole test case again from the start.

 

I've tried adding a TearDown Script within the Test Case but goes on an infinite loop and I just want it to retry 2 or 3 times then if still fails on retry stop it...

 

import com.eviware.soapui.support.types.StringToObjectMap

 

// Retrieve target test case running status, if failed, then rerun.
def testcase = testRunner.testCase.testSuite.testCases["Contract_Created"]
def testresult = testcase.run(new StringToObjectMap(), false)

 

// loop
for (int i=0; i<3; i++) {
if (testresult.status.toString() == 'FAIL') {
testresult = testcase.run(new StringToObjectMap(), false)
} else {
break
}
}

 

richie
Community Hero

Hey @Rememo,

Did you take your code from another post on the soapui forum?

I noticed there was a post by @aaronpliu and your code is IDENTICAL, excepting your for clause.

aaronplui's response to this included (i in 0..<3) in his for clause. Whereas yours is (int i=0; i<3; i++).

Tbh, i wouldve thought your code wouldve worked fine,but anyway, try changing the code and see what happens.

Ta

Rich
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

Hi @richie,

 

I tried changing the below in the TearDown Script but if the test step fails it it keeps retrying on an infinite loop and  doesn't seem to stop after the desired failed attempts.

 

for (i in 0..<3) {
if (testresult.status.toString() == 'FAIL')

richie
Community Hero

Hey @Rememo,

Thats weird cos aaronpliu's solution definitely worked before.

I'll search for other solutions or you can yourself...simply a google/forum search.....should retrieve some posts with alternative solutions.

Ta

Rich
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

@richie - Thanks for all the help 🙂

 

I'm not sure why it didn't work, but strange it went on infinite loop when I added to TearDown Script in the Test Case, I also added the Groovy Script after a Test Step but unfortunately that relies on getting to that exact groovy step but if it was to fail 2 steps before that one then Groovy wouldn't run...

 

Yea I've search as well but ReadyAPI seems very limited on answers to certain stuff people try to do...

 

I've posted before but unfortunately few answers to my questions 😞

cancel
Showing results for 
Search instead for 
Did you mean: