cancel
Showing results for 
Search instead for 
Did you mean: 

groovy script step not setting custom property value when test suite is run

SOLVED
Highlighted
Regular Visitor

groovy script step not setting custom property value when test suite is run

Hi All,

 

I have written a groovy script :

 

*************************************

import groovy.json.JsonSlurper

def jsonSlurper = new JsonSlurper()
def reader = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\Users\\userabc\\SOAPUi_File\\Token.json"),"UTF-8"))
def object = jsonSlurper.parse(reader)

println(object.access_token);

def testPro = testRunner.testCase.testSuite.project.addProperty("token")
def testPro = testRunner.testCase.testSuite.project.setPropertyValue("token",object.access_token)

********************************************

 

Now when i run the standalone groovy step within my test suite, the token custom property gets set at the project level with value.

But when i run the test suite using the launch test runner option, the groovy step though executes doesn't add or set the "token" custom property at the project level.

 

I have tried to set the value at test suite level, that also doesn't work. But as i sad if the groovy step is run standalone it works.

 

Please help. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Manager

Re: groovy script step not setting custom property value when test suite is run

Thanks, Matthew!

 

@soapui_learner were you able to solve this? Please share your solution with us.

 

Otherwise, please provide more details about the query as msiadak is asking and the community members will try to help you out.

Another way to proceed would be opening a support case if this issue requires deeper investigation. 

Thank you. 


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

3 REPLIES 3
Highlighted
Community Manager

Re: groovy script step not setting custom property value when test suite is run

Thank you for the question @soapui_learner !

 

Let's ask our scripting gurus for help🙂

@ChrisA @nmrao @msiadak @HimanshuTayal 

Could you take a look?


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Community Hero

Re: groovy script step not setting custom property value when test suite is run

@soapui_learner : Bear with me, I have a few questions. When you say it doesn't set the property when using the launch test runner, what do you see that shows that isn't happening?

 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Community Manager

Re: groovy script step not setting custom property value when test suite is run

Thanks, Matthew!

 

@soapui_learner were you able to solve this? Please share your solution with us.

 

Otherwise, please provide more details about the query as msiadak is asking and the community members will try to help you out.

Another way to proceed would be opening a support case if this issue requires deeper investigation. 

Thank you. 


Sonya Mihaljova
Community and Education Specialist

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors