使用拆卸脚本

时间:2018-05-18 18:05:42

标签: groovy automation soapui ready-api

我有一个测试案例"登录"由于登录问题而间歇性失败。 我想实现一个拆卸脚本来获取脚本的状态,如果失败则重新运行。

这是我实施的内容,并没有按预期工作。

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" 
)

即使配置为重新运行一次,脚本也会运行3次。日志

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

0 个答案:

没有答案