Lucian
7 years agoCommunity Hero
Groovy script to re-run failed tests
As Olga_T suggested here is a script which re-runs some failed tests. The script is put in the TearDown Script section at the project level.
def testSuiteResults = context.getTestRunner().getResults() def testCaseResults def runCount = 0 def testPassed = true // Iterate through each test case in the project testSuiteResults.each { it.getResults().each { // PASSED test case if ( it.getStatus().toString().equals("PASS") ) { log.info "The test case '" + it.getTestCase().getName() + "' has passed!" // FAILED test case } else { testPassed = false log.info "The test case '" + it.getTestCase().getName() + "' has failed!" // Rerunning the failed test case... while ((runCount < 2) && (testPassed == false)) { log.info "Rerunning the test one more time..."
// Ugly stuff. Sorry mom! if (it.getTestCase().run(new com.eviware.soapui.support.types.StringToObjectMap(), false).getStatus().toString().equals("PASS")) { testPassed = true log.info "The test has eventually passed!" } else { log.info "No luck... :(" } runCount++ } } } }