Forum Discussion

abdelkarim's avatar
abdelkarim
New Contributor
12 days ago

Starting Mock Service from Groovy script

Hello there,

Whenever I try getting the mock runner when the project is just loaded I get a null pointer back. I have to navigate the project tree find each mock service and open it in the virtual service editor for it to be loaded correctly and only then does the script run successfully. 

// small code extract
def server = project.getRestMockServiceByName(serverName) 
def runner = server.getMockRunner()
assert runner != null
runner.start()

What difference does opening the Virtual Service Editor in the GUI make so the mock runner is accessible? And can I simulate this in my script, some tests rely on multiple mock services in different projects, having to manually find and start them would not be ideal?

Thanks

  • abdelkarim's avatar
    abdelkarim
    New Contributor

    When trying to create a runner myself and starting it that way I get an exception: "No SSL keystore is specified for the virtual service." But none of my virtual services use https and should therefore not require a keystore.

    import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext
    import com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner
    
    // Omitted for brevity
    	
    def wsdlTestRunContext = new WsdlTestRunContext(context.currentStep)
    def mockRunner = new WsdlMockRunner(server, wsdlTestRunContext)
    mockRunner.start()