首页 > 解决方案 > SoapUI 开源项目测试用例无限循环运行

问题描述

我有一个带有测试套件设置脚本的 SoapUI 项目,它基于全局属性多次运行测试用例,但它在无限循环中运行。请帮我解决问题:

def project = null     
def workspace = runner.testSuite.project.getWorkspace();
def count=context.expand('${#Global#run}')


if (workspace != null) {
 project = workspace.getProjectByName("IQCX")
}
if (project.open && project.name == "IQCX") {
 def properties = new com.eviware.soapui.support.types.StringToObjectMap()    
 def testcase = project.getTestSuiteByName("TestSuite 1").getTestCaseByName("Login");    
 def testcase1 = project.getTestSuiteByName("TestSuite 1").getTestCaseByName("Logout");    
 if(testcase == null)
 {    
  throw new RuntimeException("Could not locate testcase 'TestCase'! ");
 } else {
// This will run everything in the selected project   
for(int i=1;i<=count;i++){
    if(i!=count){
         testcase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
        sleep(70000)
         testcase1.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
         sleep(5000)
         log.info( "Finished running "+i+" cycle" )
    }
 else if(i==count){
    log.info "count is " + i
    runner.cancel("finish it")
    testcase=null
    return null
    break;
    }
    else{
        break;
        }
 }
 
    runner.cancel("finish it")
    testcase=null
    
return null
 }
} 
else {
 throw new RuntimeException("Could not find project")
}

标签: groovysoapui

解决方案


这是通过将 def count 转换为 Integer 来解决的。不管怎么说,还是要谢谢你


推荐阅读