I use Soap UI to test my web service. I need update definitions every time I want to execute my test requests. I know that there is a possibility to add groovy script to let WSDL update automatically. But I do not know there I should add this script to make it working.Could some one describe me steps I need to do to make this script running every time I execute requests?
2 Answers
If you open your testSuite by double click on it on navigator tab you can see a setup script button at the bottom of the window, if you click the setup script button a window is displayed, you can add the groovy script on it, this script is executed at first each time that you execute the testSuite:
This it's also possible with testCases. Besides this script could be groovy or javascript, you can set which language you want setting Script Language property of your project:
Here is the code for this:
import static com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateRequests
import static com.eviware.soapui.impl.wsdl.actions.iface.UpdateInterfaceAction.recreateTestRequests
project = testRunner.testCase.testSuite.project; //get the project reference
def ifaceList = project.getInterfaceList(); //get all the interfaces present in the project in a list
//start a loop for number of interfaces
for(int i = 0; i < project.getInterfaceCount() ; i++)
{
def iface = project.getInterfaceAt(i);
def url = iface.definition;
iface.updateDefinition( url, true); //updateDefinition(String url , Boolean createRequests)
//The above part updates the definition
//The part below recreates the requests based on updated wsdl definition
//syntax -
//recreateRequests( WsdlInterface iface, boolean buildOptional, boolean createBackups, boolean keepExisting, boolean keepHeaders )
recreateRequests(iface,true,true,true,true);
recreateTestRequests(iface,true,true,true,true);
}
//End of Script//
-
The above code will create backup for all the existing requests in the project. In case you want that backup should be created only for the requests that got modified/updated , use the below statement.
iface.updateDefinition( url, false);
Feb 13, 2015 at 3:32