Very quick one to get me in the blogging mood.
So, you know when you work with API's across multiple environments using SoapUI. Depending on how your environments are structured you may need to switch proxies on or off.
After quite a while watching my tests fall over through no fault of their own I decided to solve this annoying problem. Use the following as either a setup script or a groovy step, combined with a project level property containing the URL you want to address:
import com.eviware.soapui.settings.*
import com.eviware.soapui.SoapUI
// set Proxy Dependent on Env
def aPI_URL = context.expand( '${#Project#API_URL}' )
if (aPI_URL.contains("dev")){
SoapUI.settings.setBoolean( ProxySettings.ENABLE_PROXY, false);
} else {
SoapUI.settings.setBoolean( ProxySettings.ENABLE_PROXY, true);
}
Really simple implementation shown here but it has changed the repeatibility of my tests completely. I have used similar implementations to switch within tests, dependant on which service I'm calling. You can use standard else if and switch statements with this approach too, which really changes how you can manage environments.
I find SoapUI is great for implementing really simple but flexible solutions to common environmental challenges, give it a whirl and see how manipulating your high level settings can really make your automation stand on its own two feet!
Right I'm off to see what else I can mess around with in SoapUI land.....
Comments
Post a Comment