Forum Discussion

morciani's avatar
morciani
Occasional Contributor
15 years ago

creating Test Requests with Groovy

I am having an issue dynamically creating test requests via Groovy script  I have used the forums to come up with a few simple lines of code:
______
import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory

// get request
def iface = testRunner.testCase.testSuite.project.getInterfaceByName( "PmThirdPartyRateExportIHomePolicyQuoteHttpBinding" );
def request = iface.getOperationByName( "CreateHomePolicyQuote" ).getRequestByName( "Request 1" )

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

When I attempt to run this, I get the following in the 'error log':

Thu Apr 22 11:52:01 EDT 2010:ERROR:java.lang.NullPointerException: Cannot invoke method getOperationByName() on null object
  java.lang.NullPointerException: Cannot invoke method getOperationByName() on null object
  at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
  at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
  at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:17)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
  at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
  at Script27.run(Script27.groovy:6)
  at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93)
  at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:51)
  at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
  at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)

Please let me know if I can provide any additional detail.  Any help is appreciated!!!!!
No RepliesBe the first to reply