Forum Discussion

robinjmk's avatar
robinjmk
Visitor
4 years ago

How to Update a SOAP MockService (XML) from a Groovy Script

HI teams, 

I am trying to implement data driven testing using Groovy. 

I have added an existing Mock Request as a step to the test suite and am updating this Test step using Groovy, by passing in values from a csv to this xml (code below):


def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def tc = "MockStep#Request"
def holder = groovyUtils.getXmlHolder( tc )
holder["//Variable_001"] = "13132132" // Change the value of the node
holder.updateProperty()


This works fine,

 

But I want to update the Mock response directly, and am unable to do this. This is the code I have tried

1. (this throws an error)


def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def tc = testRunner.testCase.testSuite.project.getInterfaceAt(0).getOperationAt(0).getRequestAt(5)
def holder = groovyUtils.getXmlHolder( tc )
holder["//Variable_001"] = "13132132" // Change the value of the node
holder.updateProperty()

 

2.(this doesnt throw an error but the mock response doesnt update)

 

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def tc = testRunner.testCase.testSuite.project.getInterfaceAt(0).getOperationAt(0).getRequestAt(5).getRequestContent()
def holder = groovyUtils.getXmlHolder( tc )
holder["//Variable_001"] = "13132132" // Change the value of the node
holder.updateProperty()

 

Can anyone please guide me as to how i can achieve this update of values being passed directly to teh Mock Request?

 

No RepliesBe the first to reply