Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用groovy循环以在soapui中执行测试用例_Groovy_Soapui - Fatal编程技术网

使用groovy循环以在soapui中执行测试用例

使用groovy循环以在soapui中执行测试用例,groovy,soapui,Groovy,Soapui,我想使用groovy在soapui中运行5次测试用例。 我在Stackoverflow中找到了以下代码,并添加了循环部分,但它是随机执行的。 有时执行2次,有时执行4次 代码如下: def a = 5; while (a>0) { a--; def testCase = testRunner.testCase.testSuite.testCases["TestCase"]; def properties = new com.eviware.soapui.support.types.S

我想使用groovy在soapui中运行5次测试用例。 我在Stackoverflow中找到了以下代码,并添加了循环部分,但它是随机执行的。 有时执行2次,有时执行4次

代码如下:

def a = 5;
while (a>0) {
a--;

def testCase = testRunner.testCase.testSuite.testCases["TestCase"];  
def properties = new com.eviware.soapui.support.types.StringToObjectMap();  
def async = false;  
testCase.run(properties, async);
}

谢谢

首先,您不想在脚本中定义测试用例,因为通常为您定义测试用例

def doSomething() {
    println 'Foo Bar'
}

5.times { 
    doSomething() 
}
def myTestCase = testSuite.getTestCaseByName("some TestCase")
def myContext = (com.eviware.soapui.support.types.StringToObjectMap)context
5.times {
    myTestCase.run(myContext, false)
}

您也没有指定从何处执行此操作。上述代码将在测试套件设置脚本中运行。如果您在其他地方执行此操作,您可能需要调整
def myTestCase

我在测试套件的设置脚本中有以下脚本,并且它正在运行无限循环:

 def count=context.expand('${#Global#run}')
    log.info count
    
    def project1 = runner.testCase.testSuite.project
     def properties = new com.eviware.soapui.support.types.StringToObjectMap()    
     def testcase = project1.getTestSuiteByName("TestSuite 1").getTestCaseByName("Login");    
     def testcase1 = project1.getTestSuiteByName("TestSuite 1").getTestCaseByName("Logout");    
     
   
    // This will run everything in the selected project   
    for(int i=1;i<=count;i++){
     // testRunner = testcase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
        def myContext = (com.eviware.soapui.support.types.StringToObjectMap)context
        testcase.run(myContext, false)
        sleep(70000)
        //testRunner = testcase1.run(new com.eviware.soapui.support.types.StringToObjectMap(), false)
        testcase1.run(myContext, false)
        sleep(5000) 
        log.info( "Finished running "+i+" cycle" )
     if(i==count){
        testRunner.cancel('Test Execution is completed')
        break;
        }
     }
 
def count=context.expand(“${Global}run}”)
日志信息计数
def project1=runner.testCase.testSuite.project
def properties=new com.eviware.soapui.support.types.StringToObject映射()
def testcase=project1.getTestSuiteByName(“TestSuite 1”).getTestCaseByName(“登录”);
def testcase1=project1.getTestSuiteByName(“TestSuite 1”).getTestCaseByName(“注销”);
//这将运行所选项目中的所有内容

对于(int i=1;我也有同样的问题,只是想知道:为什么“…使用groovy”?你不能在SoapUI中只使用普通的GoTo步骤吗?不,我不想使用SoapUI步骤。我想使用groovy步骤。我不明白groovy是如何知道testsuite名称的请尝试文档: