Forum Discussion
Let me see what I can figure out. :)
Did you get it to work!? :)
- groovyguy6 years agoChampion Level 1
Sorry for the delay, took some fine tuning and I've been a bit busy. But, here's the basics of a groovy script that can set up environments. Right now, it'll set up one environment and populate it with the REST endpoint. Let me know if you run into any issues. It can also be adapted to add SOAP services/endpoints.
import com.eviware.soapui.model.environment.* import com.eviware.soapui.config.* def project = context.testCase.testSuite.project; // Assuming binding is the first interface on the project. def binding = context.testCase.testSuite.project.getInterfaceAt(1).getName().toString(); // Getting current list of environment names def environNames = project.getEnvironmentNames().toString(); // Names of environments to add def name = "env1" // Environment URLs, number should match number in previous array for environment names project.addNewEnvironment(name); project.setActiveEnvironment(name); def environ = project.getActiveEnvironment(); def newService; // For REST service: newService = environ.addNewService(binding, com.eviware.soapui.config.ServiceConfig.Type.REST); def serviceConfig = newService.getConfig(); def endpointConfig; endpointConfig = serviceConfig.addNewEndpoint(); newService.buildEndpoint(endpointConfig); def isCopy1 = true; log.info(isCopy1); environ.populateService(newService, isCopy1); environ.release();
- groovyguy6 years agoChampion Level 1
Still no luck on this one, and I've come up in a situation where I need it as well. Still working it :)
- groovyguy6 years agoChampion Level 1
My team and I had a breakthrough. Let me clean up our code and I can share something that should help with setting up REST services/endpoints. It works for me for SOAP endpoints so it should not be that far off to configure and change for REST.
- groovyguy6 years agoChampion Level 1
I had to enlist some help from coworkers, Lucian, but we managed to get it after a few days of knocking our heads together. Ended up being that I really needed a similar script since I need my test team to implement environments to support automated jenkins testing. So I had a bit of extra incentive. :)
- Olga_T6 years agoSmartBear Alumni (Retired)
Hi all,
Thank you guys for your time looking into this! I was following the discussion with keen interest :smileywink:
stewmoon, have you had a chance to try the solution?
If it works, can you please click the Accept as Solution button below the appropriate answer?
Thanks,