Ask a Question

ReadyAPI - Understanding the result returned by a groovy script?

SOLVED
rajs2020
Frequent Contributor

ReadyAPI - Understanding the result returned by a groovy script?

The docs say that a groovy script can return a result named as "result". See link - https://support.smartbear.com/readyapi/docs/functional/steps/groovy.html


I have some test steps which run/call a test case which contains a groovy script. I need to access the result of the script inside the custom properties of the test which calls that script. My questions -

1 - How to access the result returned by a groovy script ?
2 - How to return multiple values in the result & access them ?

thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
HimanshuTayal
Community Hero

Re: ReadyAPI - Understanding the result returned by a groovy script?

@rajs2020 : By below way you can access the result returned by Groovy Script:

 

def val = 1

return val;

 How you can use:

${GROOVY_TEST_STEP_NAME#result}

 

M not sure on how to return multiple value, my guess is you can use array for it or else you can use run time context variable

 

set the context variable property,

context.setProperty("val1",val1)
context.setProperty("val2",val2)


How to fetch it,

log.info context.getProperty("val1")
log.info context.getProperty("val2")

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

View solution in original post

3 REPLIES 3
HimanshuTayal
Community Hero

Re: ReadyAPI - Understanding the result returned by a groovy script?

@rajs2020 : By below way you can access the result returned by Groovy Script:

 

def val = 1

return val;

 How you can use:

${GROOVY_TEST_STEP_NAME#result}

 

M not sure on how to return multiple value, my guess is you can use array for it or else you can use run time context variable

 

set the context variable property,

context.setProperty("val1",val1)
context.setProperty("val2",val2)


How to fetch it,

log.info context.getProperty("val1")
log.info context.getProperty("val2")

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

View solution in original post

rajs2020
Frequent Contributor

Re: ReadyAPI - Understanding the result returned by a groovy script?

@HimanshuTayal- what is "run time context variable"?

HimanshuTayal
Community Hero

Re: ReadyAPI - Understanding the result returned by a groovy script?

@rajs2020 : These are the variables which are created at runtime and remains in the memory until your script is running

 

Refer below article for more information on the same

 

Soapui-using-context-variables 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
cancel
Showing results for 
Search instead for 
Did you mean: