cancel
Showing results for 
Search instead for 
Did you mean: 

Adding service steps with groovy

Highlighted
Not applicable

Adding service steps with groovy

I know that with groovy you can add any of the steps that come built in as is shown in the tutorial. But, let's say that I'm testing the amazon service and I want to add the CartAdd step to my testcase.

How do I add request steps to the test case? I tried to do something
crazy. See below for what I did.

// add a properties step

def step = (com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep)(testRunner.getTestCase().getTestSuite().getTestCaseByName( "haha").getTestStepByName( "CartClear" ) )

((com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep)testRunner.testCase).importTestStep( (step), "CartAdd", 1  );
1 REPLY 1
Highlighted
Super Contributor

Hi Jerry,

try the following for adding an existing "CartAdd" request named "Request 1" to the current testcase as a TestRequest with a SoapResponse assertion..

import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory
import com.eviware.soapui.impl.wsdl.teststeps.assertions.SoapResponseAssertion

// get request
def iface = testRunner.testCase.testSuite.project.getInterfaceByName( "AWSECommerceServicePortType" )
def request = iface.getOperationByName( "CartAdd" ).getRequestByName( "Request 1" )

// create config and add teststep
def config = WsdlTestRequestStepFactory.createConfig( request, "CartAdd RequestStep" )
def testStep = testRunner.testCase.insertTestStep( config, -1 )

// add a soapresponse assertion
testStep.testRequest.addAssertion( SoapResponseAssertion.ID )


You need to be sure that the name specified in the createConfig call is unique for the testcase, otherwise a prompt will be displayed for a new name..

Hope this helps!

regards,

/Ole
eviware.com
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors