如何用soapui groovy脚本执行特殊测试用例?

时间:2012-02-01 06:01:05

标签: groovy soapui

如何使用soapui groovy脚本执行特殊测试用例?

testRunner.runTestCaseByName(' ExitGame&#39);

3 个答案:

答案 0 :(得分:2)

更紧凑 - 对于上述问题,要执行任何特定步骤,请添加另一行

def tc = testRunner.testCase.testSuite.project.testSuites["TestSuite1"].testCases["TestCase3"]

def ts1 = testRunner.gotoStepByName("loginRequest1")

答案 1 :(得分:1)

找到可能有帮助的page here

此处复制的代码(并使用您的套件名称更新)为后代

import com.eviware.soapui.impl.wsdl.panels.support.MockTestSuiteRunner;
import com.eviware.soapui.impl.wsdl.panels.support.MockTestSuiteRunContext;

project = testRunner.getTestCase().testSuite.getProject()
testSuite = project.getTestSuiteByName( "ExitGame" )

mockRunner = new MockTestSuiteRunner( testSuite )
mockContext = new MockTestSuiteRunContext( mockRunner )
testSuite.runTearDownScript( mockContext, mockRunner )

答案 2 :(得分:0)

您也可以遵循此-

def project = context.testCase.testSuite.project
def TestSuite = project.getTestSuiteByName("TestSuite_Name")
def testCase1 = TestSuite.getTestCaseByName("ExitGame") // Put your testCase Name here
def testStep1 = testCase1.getTestStepByName("REST Step 1") // Put your testStep Name

// Run testStep only
testStep1.run(testRunner, context)

// Run testCase [here it is "ExitGame"]
def properties = new com.eviware.soapui.support.types.StringToObjectMap()
testCase1.run(properties, false)

或者您也可以通过以下脚本来运行testCase

testCase1.run(null, true) // You don't need to have `properties` in this case.

警告:以上脚本应位于不同的testCase / testStep中。如果在同一testCase中,它将无限循环