Forum Discussion

sprei_09's avatar
sprei_09
Occasional Contributor
7 years ago
Solved

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.

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Would you mind showing how is your data that needs to be loop thru?

    Also how your request is supposed to be?