Forum Discussion
Hi Ricardo,
Thank you for your post! You can try the following script:
log.info "Name = " + context.mockService.name
And, to get a value of a custom property, you can use the following:
// REST Virt
log.info "getPropertyName = " + context.modelItem.project.getRestMockServiceByName("Name of your Virt").getPropertyValue("Name of your property")
// SOAP Virt log.info "getPropertyName = " + context.modelItem.project.getMockServiceByName("Name of your Virt").getPropertyValue("Name of your property")
thanks for fast reply Anastasia
in both scripts, the aplication only can get MockService properties value, i need obtain mockResponse's name, 2 levels below on the project tree:
I created in the MockService a custom property called "resultName" for the following script, insert an "hard coded" value and, with your second script, to get the property value and log it.
def resultName = context.mockService.setPropertyValue("resultName","Response1")
It works fine, but I have many mock responses and does this for each is unviable.
thanks again
- nmrao7 years agoChampion Level 3ricardo_moura, are you able to get it yet or not?
- ricardo_moura7 years agoOccasional Contributor
i able, but not is the best way, with this method i set/get custom property from MockService, not from MockResponse
i have a lot of MockResponses, do that to everyone costs a lot of time
- groovyguy7 years agoChampion Level 1
You could potentially use a groovy script to automate accessing the ReadyAPI api itself to set these for all of your tests. You'd have to study up on the API documentation though.