Forum Discussion

soapui_learner's avatar
soapui_learner
Regular Visitor
4 years ago
Solved

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. 

  • sonya_m's avatar
    sonya_m
    4 years ago

    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. 

3 Replies

    • groovyguy's avatar
      groovyguy
      Champion Level 1

      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?

       

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        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.