cancel
Showing results for 
Search instead for 
Did you mean: 

Reexecution failed test in test suite

SOLVED
vikititor
Contributor

Reexecution failed test in test suite

Hello all, here is script provided by SmartBear support.. but script ends in loop.. They are unable to help me..

Basically.. is there any way? how to re-execute failed tests? I have ReadyAPI 3.7.. 

 

Integer reexecutionCount = context.testSuite.project.getPropertyValue("reexecutionCount");
String reexecutionTestPattern = context.testSuite.project.getPropertyValue("reexecutionTestPattern");
log.info "  *  *  *  REEXECTUION FAILED TESTS TestSuite: " + context.testSuite.name
//log.info "reexecutionTestPattern: " + reexecutionTestPattern
//log.info "reexectution max: " + reexecutionCount.toString();
String testName;

// select all tests in FAIL run status:
for ( testCaseResult in runner.results ) {
    if ( testCaseResult.getStatus().toString() == 'FAIL' ){
        testName = testCaseResult.getTestCase().name
        //  log.info "failed test: " + testName
        // whenm matches the name of thest the project property using RegExp, then go and execute
        if (testName.matches(reexecutionTestPattern)) {
            for (i = 0; i < reexecutionCount; i++) {
               log.info "REEXECUTION TestCase: " + testName
                def tRun = testCaseResult.testCase.run(null, false)//need to have "true" as the second argument
                if(tRun.getStatus().toString() == "PASS"){
                    break;
                    }   
                }
            }
        }
    }
1 ACCEPTED SOLUTION

Accepted Solutions
joejoyce
Staff

Re: Reexecution failed test in test suite

Hey @vikititor.

 

Have you tried the script example given here?

 

It's slightly different to the one you're using now, but I've tested it on my machine and it works fine once you've added a Test Suite property to specify how many times you want the tests to rerun after failure.

 

Let me know if you have any more success with this one!

View solution in original post

1 REPLY 1
joejoyce
Staff

Re: Reexecution failed test in test suite

Hey @vikititor.

 

Have you tried the script example given here?

 

It's slightly different to the one you're using now, but I've tested it on my machine and it works fine once you've added a Test Suite property to specify how many times you want the tests to rerun after failure.

 

Let me know if you have any more success with this one!

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors