1

I have a test case "Login" which intermittently fails due to login issues. I would like to implement a tear down script to get the status of the script and rerun if it failed.

Here is what I implemented and it doesn't work as expected.

testRunner.testCase.setPropertyValue("LoginStatus", 
testRunner.getStatus().toString())

def loginStatus = context.expand( '${#TestCase#LoginStatus}' )

int retryAttempts = context.expand( '${#Project#RetryAttempts}' ).toInteger()

def myContext = (com.eviware.soapui.support.types.StringToObjectMap)context

while ( loginStatus == "FAIL" && retryAttempts <= 1)  {
  retryAttempts = retryAttempts+1
  log.info "increment retry attempts-" + retryAttempts
  testRunner.testCase.testSuite.project.setPropertyValue( "RetryAttempts", 
   retryAttempts.toString() )
  testCase.run(myContext, false)
  log.info "after run statement-"+retryAttempts
}
log.info "before final statement"
testRunner.testCase.testSuite.project.setPropertyValue( "RetryAttempts", "0" 
)

The script runs 3 times even though it is configured to rerun once. The logs

Fri May 18 13:55:15 EDT 2018:INFO:increment retry attempts-1
Fri May 18 13:55:16 EDT 2018:INFO:increment retry attempts-2
Fri May 18 13:55:16 EDT 2018:INFO:before final statement
Fri May 18 13:55:16 EDT 2018:INFO:after run statement-2
Fri May 18 13:55:16 EDT 2018:INFO:before final statement
Fri May 18 13:55:16 EDT 2018:INFO:after run statement-1
Fri May 18 13:55:16 EDT 2018:INFO:increment retry attempts-2
Fri May 18 13:55:17 EDT 2018:INFO:before final statement
Fri May 18 13:55:17 EDT 2018:INFO:after run statement-2
Fri May 18 13:55:17 EDT 2018:INFO:before final statement
ChanChow
  • 1,346
  • 7
  • 28
  • 57
  • I think its better to rerun stepwise, instead of running as a testcase because it looks like teardown script is running everytime which is making it tun thrice.. i.e.testCase.run(myContext, false) when this is run first time, it makes it run the teardown script as well, so its kind of recursion – Gaurav Khurana May 21 '18 at 03:01
  • hello, have you tried a gotoStep ? ie, something like testRunner.gotoStepByName("your_testcase_first_step") – A.Joly Jun 13 '18 at 06:53

0 Answers0