To Add an Step right click on the Test case and choose the script type.
To see any values log the value
def val = "fffff";log.info(val);
Use Groovy script to do any tasks which are not already available.
to create a new property at test case leveldef newProperty = 'Test' + System.currentTimeMillis();
testRunner.testCase.setPropertyValue("newProperty", newProperty);
And then it can be used in a subsequent step with
def property1 = context.expand( '${#TestCase#newProperty}')
Reading xml request and response for soap steps
after the step can use following groovy script step to save the request and response to testcase level properties//first grab the request, response , row request, row response.
def request = testRunner.testCase.getTestStepByName("stepName").getProperty("Request").getValue();
def response = testRunner.testCase.getTestStepByName("stepName").getProperty("Response").getValue();
def rawRequest = testRunner.testCase.getTestStepByName("stepName").getProperty("RawRequest").getValue();
def rawResponse = testRunner.testCase.getTestStepByName("stepName").getProperty("RawResponse").getValue();
//then save them to testcase level properties.
testRunner.testCase.setPropertyValue("xmlRequest", request);
testRunner.testCase.setPropertyValue("xmlResponse", response);
testRunner.testCase.setPropertyValue("rawRequest", rawRequest);
testRunner.testCase.setPropertyValue("rawResponse", rawResponse);
To query database
create a database step and select appropriate driver and connection string. place the drive in the SoapUI jars folder.
write a SQL select query and execute and see the results in the response pane.
to grab the results for assertions add an script assertion
click on the database script step, click on Assertions tab, click on + and select Script Assertion
right click and select Get Data > pick the step or test case to get the data from, eg the database step and then pick a variable.
let's say we picked ResponseAsXml
then click on Add button, pick the element from the xml view.(xpath expression is displayed when the element is selected). click OK. give a name for the property. click OK. this will add a linie to the script. something like below.
def responseAsXml = context.expand( '${MyStepName#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/COMMUNICATION_ID[1]}' )