Data Driven Testing for SoapUI Free Version for REST POST Call.
I need to run a data driven testing for a POST request mentioned as below using the SoapUI Free version. Please help.
URI : http://serverIP:port
Request Body : {"get_range": ["100.169.145.70"] }
Response Body : {"ip_ranges": [{ "ip": "100.169.145.70", "ipint": 1688834374, "end": 1688862719, "start": 168879718n4 }]}
Automation Script :
The script for single request is working. However, to make it data-driven, I have created an array with the request body and wanted to pass it to the test. The script for multiple request blobs is failing. Script :
import groovy.json.JsonSlurper
//DataDriven Testing
//def ipsArray = new String[2]
//ipsArray[0]='{"get_range": ["81.169.145.70"] }'
//ipsArray[1]='{"get_range": ["190.169.145.70"] }'
//def IpRangeRequestStep = testRunner.testcase.getTestStepByName(IpRangeRequest-1)
//def IpRangeRequest = IpRangeRequestStep.getTestRequest()
//ipRangeTest.setRequestContent(ipsArray)
//testRunner.runTestStepByName(IpRangeRequest-1)
//
def ipRangeTest = testRunner.runTestStepByName("IpRangeRequest-1")
def response = ipRangeTest.getResponse()
def jsonStr = response.getContentAsString()
JsonSlurper serializer = new JsonSlurper()
def object = serializer.parseText(jsonStr)
log.info(object.size())
object.each{ log.info(it) }
Attached is the screen capture of how the test was created.
- Something similar was done sometime ago. Would you please check if you can follow the same?
https://stackoverflow.com/questions/44307973/how-to-run-a-web-service-for-multiple-values/44312672#44312672