Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

scripting groovy TestSuite Variable REST

jngojngo
jngojngo Posts: 46

I do this in all my SOAP messages to store TestSuite Variable and it works perfectly. However, when I apply the same logic to REST. It doesn't work.

myTransactionId ='1234'
suite = context.getParentContext().getParentContext();
TS_Var = "uniqueId"
myVar = suite.get(TS_Var);
suite.put(TS_Var, myTransactionId )

I notice that the call on context.getParentContext() does return a value but it's not related to the scenario case at all. Am I missing something or I should apply a different method call on REST.

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Any particular reason why you don't just do context.setValue(TS_Var, myTransactionId)? This will find the variable from the correct context automatically.

  • jngojngo
    jngojngo Posts: 46

    there's another element within the same request. That would be either have the same value or unique value created. Futhermore, I would also like to call it on globally on a method call

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    You are only asking about accessing a test suite variable, isn't this correct? The "setValue" and "getValue" methods are what you should use for getting and setting test suite variables. Those methods automatically locate the test suite where you previously defined the variable (on the suite's "Variables" tab).

  • jngojngo
    jngojngo Posts: 46

    You are absolutely right Ben. Thanks.