Brijesh Bharadwaj
Brijesh Bharadwaj

Reputation: 318

How can i start all mock services when SoapUI starts?

Are there any command line parameters, or other ways, so that all the mock services start up when soap ui is started?

Upvotes: 8

Views: 5811

Answers (6)

FluffyBike
FluffyBike

Reputation: 2422

If anyone tries this in SoapUi 5.7.0, you will have to uncheck the box for Disable the Load and Save Scripts before you can run any scripts. The setting can be found under File -> Preferences -> Global Security Settings.

If you don't uncheck this checkbox, neither load- nor save scripts will run. You will get a line in the SoapUI log that works as a hint:

Fri Jul 29 12:47:06 CEST 2022:WARN:In project 'ProjecName (YourService v1.1)' we have detected Save script that may contain malicious code, if you do not want to receive this message please change the setting in preferences.

Upvotes: 2

cederlof
cederlof

Reputation: 7383

I use this Groovy-script to start all mock-services in a project (set up in "Load Script"-tab in the Project View.

mockServicesCount = project.getMockServiceCount()
for (i in 0..(mockServicesCount-1)) {
    project.getMockServiceAt(i).start();
    i++;
}

Upvotes: -1

user1207289
user1207289

Reputation: 3273

Was looking same for rest mock services . For that use this instead ,from test suite setup script. Just in case anyone lands here while searching, like i landed. This can also be use from project or test case level by accordingly modifying it.

 testSuite.project.getRestMockServiceByName("Service1").start()

Upvotes: 3

Seymour
Seymour

Reputation: 7067

As defined on the soapUI Support Forum, you can add the following code as a "load script" for your project:

for( mockService in project.mockServiceList )
{
    def windowReference = com.eviware.soapui.support.UISupport.showDesktopPanel( mockService )
    mockService.start() 
    com.eviware.soapui.SoapUI.desktop.minimize( windowReference  )
}

soapUI Support Forum Reference:
http://forum.soapui.org/viewtopic.php?f=5&t=1138

Upvotes: 1

user2726132
user2726132

Reputation: 61

Since the mockServices is a Map this will also work:

project.mockServices.each() { entry -> entry.value.start() }

Upvotes: 6

Kris
Kris

Reputation: 503

You can automate this with the help of a Groovy Script.

  1. Double click on the Project (inside the Navigator pane)
  2. Open the tab "Load Script"
  3. Following script can be used as an example:

    project.getMockServiceByName("name_of_your_mock_service_01").start(); project.getMockServiceByName("name_of_your_mock_service_02").start();

Upvotes: 7

Related Questions