I have free version of Soap UI 5.4.0. We have multiple environments like Dev, ST, SIT, UAT. I am aware that i cannot create environment specific files in Soap UI free version. (In postman its possible but limitation of NTLM authentication). My question is it possible to populate headers, NTLM credentials, and Server URL based on some end point or variables or any other option, so that i can switch environment quickly and as and when required. (Just like we do in Postman by changing dropdown all required values get populated)
So far i have done the following.
I have created required headers as per environment and exported them to file and import appropriate header file when while switching
Added server URLS under endpoint. (There is option to use Username & Password i don't know how to populate those values in NTLM authentication based on end point selection, i have to manually add/modify when changing environment)
Is this the proper way to add environment specific headers, server URL & NTLM credentials. Or is there a proper way to do it.
Thanks in advance.
The environment switching feature in soapUI Pro is very nice, but I work mostly with the OSS version so I've had to create my own utility along the same lines.
First, you'll need a collection of property files, one for each environment (local, dev, test, uat, ...). The names of the individual properties in each file will be the same and only the value will change from environment to environment. For example, in soapui.local.properties
:
webservice.endpoint=http://localhost:8080/webservice
database.username=frodo
database.url=jdbc:mysql://localhost:3306/middleearth
And, in soapui.dev.properties
:
webservice.endpoint=https://dev.server.com:8080/webservice
database.username=frodo_dev
database.url=jdbc:mysql://dev.database.server:3306/middleearth
Save the property files with names in the following format: soapui.<environment>.properties
. For example:
soapui.local.properties
soapui.dev.properties
soapui.uat.properties
Then, I use the following Groovy script to pop up a dialog box to select a property file and set those values as project-level properties in soapUI:
import com.eviware.soapui.support.UISupport;
import com.eviware.soapui.support.types.StringToStringMap;
import com.eviware.x.form.XForm;
import com.eviware.x.form.XFormDialog;
import com.eviware.x.form.XFormDialogBuilder;
import com.eviware.x.form.XFormFactory;
log.info project.getName()
envDialog = new EnvironmentDialog(log)
if (envDialog.configure()) {
target = envDialog.getEnv()
path = context.expand(project.getResourceRoot())
file = path + "\\environment." + target + ".properties"
log.info "Loading property file $file"
project.addPropertiesFromFile(file)
}
return
public class EnvironmentDialog {
private static final String ENVIRONMENTS = "Environments";
private XFormDialog dialog;
private String env;
def log
public EnvironmentDialog(org.apache.log4j.Logger logger)
{
log = logger
}
public boolean configure() {
if (dialog == null) {
buildDialog();
}
StringToStringMap values = new StringToStringMap();
dialog.setOptions(ENVIRONMENTS, new String("local,dev,test,uat").split(","));
values = dialog.show(values);
if (dialog.getReturnValue() == XFormDialog.OK_OPTION) {
try {
env = values.get(ENVIRONMENTS)
log.info "set env = " + env
return true
}
catch (Exception e) {
UISupport.showErrorMessage(e.getMessage());
return false
}
}
return false
}
public String getEnv() {
return env
}
private void buildDialog() {
XFormDialogBuilder builder = XFormFactory
.createDialogBuilder("Pick Environment");
XForm form = builder.createForm("Basic");
form.addComboBox(ENVIRONMENTS, new String[0], "Environment options");
dialog = builder.buildDialog(
builder.buildOkCancelActions(),
"SOAPUI Test Properties target selected environment",
UISupport.OPTIONS_ICON);
}
}
Set the file path to the fully qualified location of your property files.
To use the properties within soapUI, I just reference the project property such as ${#Project#webservice.endpoint}
wherever I need it. When I want to switch environments, I just rerun the script.
I typically run the script from the project's Load Script tab. If the script doesn't run for you, check your Global Security Settings in your preferences and uncheck the Disable the Load and Save Script checkbox.