chanukya
6 years agoOccasional Contributor
rerun a test case in ready api using tear down script
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" )
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
Question: How does the teardown script behave?
I am expected a Failed test at the first run. So it has to jump to run the test again and either go or exit since we reached the limit. But it runs 3 times.
Could some one explain how tear down script works.