Abhishek Kotalwar
Abhishek Kotalwar

Reputation: 528

How to access a custom property in mock service groovy script?

Is there any way to access the mock service custom properties, from a mock operation groovy script?

Please check image, custom properties shown left bottom corner which are mock service properties.

Please check image

Upvotes: 1

Views: 1267

Answers (1)

albciff
albciff

Reputation: 18517

To access a Mock service custom property from inside the Mock script itself you can use the property expansion as follows:

From the SOAPUI documentation:

#MockService# - references a MockService property in the containing MockService

So this can do the trick:

context.expand('${#MockService#YourPropertyName}')

For you specific case:

def userId = context.expand('${#MockService#UserID}')
def password = context.expand('${#MockService#Password}')

Upvotes: 4

Related Questions