Reputation: 101
how to execute special test case with soapui groovy script?
testRunner.runTestCaseByName('ExitGame');
Upvotes: 1
Views: 10474
Reputation: 1683
You can follow this as well -
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)
Or You can run the testCase by following script as well
testCase1.run(null, true) // You don't need to have `properties` in this case.
Caution: The above script should be in different testCase/testStep. If it is in same testCase, it will in infinite loop
Upvotes: 0
Reputation: 33
The more compact one would be - for above question, To execute any particular the step add another line
def tc = testRunner.testCase.testSuite.project.testSuites["TestSuite1"].testCases["TestCase3"]
def ts1 = testRunner.gotoStepByName("loginRequest1")
Upvotes: 2
Reputation: 171054
Found a page here that might help?
Code copied here (and updated with your suite name) for posterity
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 )
Upvotes: 1