cancel
Showing results for 
Search instead for 
Did you mean: 

Retry a test case 3 times before it marks failed

SOLVED
API_Guy
Occasional Contributor

Retry a test case 3 times before it marks failed

Hi There,

I am very new to SOAP UI Pro and I have test cases that has 22 test steps in a single test case, starting from login to book a ticket in an application. 

I am trying to make this test dynamic such as if it encounters any failure in any of the test steps then the test case should be triggered again 3 times before it markes failed.

So, I want to re-run the test case automatically for at least 3 times if it encounters any errors in any steps.

 

Can anyone please help me with how I can achieve it?

 

Thanks in advance!
Appreciate your help!!

 

1 ACCEPTED SOLUTION

Accepted Solutions
aaronpliu
Frequent Contributor

Re: Retry a test case 3 times before it marks failed

Simple solution:

Retrieve target test case running status, if failed, then rerun.

 

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

//
def testcase = testRunner.testCase.testSuite.testCases["TargetTestCaseName"]
def testresult = testcase.run(new StringToObjectMap(), false)

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

View solution in original post

Tags (1)
4 REPLIES 4
HimanshuTayal
Community Hero

Re: Retry a test case 3 times before it marks failed

@API_Guy : You can achieve this by writing your custom groovy code to achieve this.

 

Create a Controller Test Case from where run the desired testcase.

At the end check the status of test case if it is fail then run the test case desired number of times.


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
API_Guy
Occasional Contributor

Re: Retry a test case 3 times before it marks failed

Thanks @HimanshuTayal for your response. But in that case, my report will also count the controller as a separate test case, right? That's what I don't want. The test case count in my report should be unchanged.

 

Also, can you help with how I can achieve that controller using groovy? Any snippet would be helpful.

 

Thanks much! Appreciate your help!

aaronpliu
Frequent Contributor

Re: Retry a test case 3 times before it marks failed

Simple solution:

Retrieve target test case running status, if failed, then rerun.

 

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

//
def testcase = testRunner.testCase.testSuite.testCases["TargetTestCaseName"]
def testresult = testcase.run(new StringToObjectMap(), false)

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

View solution in original post

Tags (1)
sonya_m
Community Manager

Re: Retry a test case 3 times before it marks failed

Thank you, everyone!

 

@API_Guy have you tried the recent suggestion? Please share your results🙂


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors