Reputation: 1467
I am writing a groovy script to test my all services in one single step.
I imported the WSDL and then all the SOAP request are generated automatically.
I want to reduce my manual work of testing all the SOAP services one by one.
So, I want to do it via groovy if possible.
From here in addressScript - I want to access all the SOAP requests in all the test cases later. so is it possible to implement it via some looping in context ..? Below is sample code am trying .
My main moto is to reduce all the manual work of testing all SOAP requests one by one.
import org.apache.commons.httpclient.methods.PostMethod;
import org.w3c.dom.*;
class Example {
static void main(String[] args) {
String serviceInput="";
PostMethod post = new PostMethod(");
post.setRequestHeader("Accept", "application/soap+xml,application/dime,multipart/related,text/*");
post.setRequestHeader("SOAPAction", "");
def req = context.testCase.getTestStepAt(context.currentStepIndex - 1).httpRequest.requestContent
log.info req
// here i want to access all the SOAP requests in loop , and to test all the services in sequence
}
}
Upvotes: 0
Views: 1287
Reputation: 21389
From the image that you have attached, it looks like SOAP
request steps are being used in your case.
Here is the Groovy Script
.
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
//Loop thru all the test cases of test suite
context.testCase.testSuite.testCaseList.each { testKase ->
//Loop thru all the test steps of each test case
testKase.testStepList.each { step ->
//Check if the request type is SOAP
if (step instanceof WsdlTestRequestStep) {
//Get the request of test step
def stepRequest = step.getPropertyValue('Request')
log.info "Request of step ${step.name} is :\n ${stepRequest}"
} else {
log.info 'Ignoring step as it is not SOAP request type step'
}
}
}
Not really sure, what you wanted to do once you get the request. Anyways, stepRequest
variable will have the request data, for now just logging as you see in the above code.
Upvotes: 2