Reputation: 962
I was trying to use environment feature which is available in Soapui 4.5 pro and it is not working :( Anyone tried this before or is there any other way to achieve this? For me, each environment will have different DB connections and API end points. Help much appreciated.
http://www.soapui.org/Working-with-Projects/environment-handling-in-soapui.html
Upvotes: 0
Views: 4072
Reputation: 1060
You could try to use a 'Load script' for the project:
This script always executes when you run soapui or testrunner and gets the endpoint (or some other parameter e.g. DB connection) from the config file.
Script code:
import com.eviware.soapui.SoapUI
import com.eviware.soapui.model.testsuite.TestRunner
def utils = new com.eviware.soapui.support.GroovyUtils(context)
// load config file
def pathConfig = utils.projectPath + "/<path to your project>/config/"
def config = new java.util.Properties()
config.load(new java.io.FileInputStream(pathConfig + "config.ini"))
// set the project endpoint from the config
props = project
props.setPropertyValue("Env", config.getProperty("endpoint"))
log.info "Running test for: " + config.getProperty("endpoint");
As you can see the script puts your endpoint into the custom project variable Env. So in all your requests you should use the endpoint http://${#Project#Env}.
Config file:
endpoint = dev.mysite.com
Solution is also available for non pro version
Upvotes: 1
Reputation: 29
To get DB connection, you can use GroovyUtilsPro Class, https://www.soapui.org/apidocs/pro/com/eviware/soapui/support/GroovyUtilsPro.html
eg.
def utils = new com.eviware.soapui.support.GroovyUtilsPro(context)\
def conn = utils.getJdbcConnection("{the Name of your JDBC Connections in Environments}")
this is for soapUI pro only. I am still looking for how get services endpoint from 'Environments' setting.
Upvotes: 0