Forum Discussion

PrashantS's avatar
PrashantS
New Contributor
8 years ago

Is it possible to use same object reference in two different groovy steps?

I am trying to use a reference of extent report created in one groovy step in another groovy step. Is there a way to store the reference temporarily (like properties) so that i can retrieve the reference in any step and continue to modify the same report from different steps?

  • nmrao's avatar
    nmrao
    Champion Level 3
    SoapUI supports custom properties where user can store string values at test case / suite or project level, so one can use them later.

    What kind of data you want to access between the groovy scripts? If it is string data, then like I mentioned earlier, store the data at appropriate level and access it using property expansion where you needed it later.

    If the data is complex ( not just string) such as object, then there is one option to be able to share between the scripts provided if both the groovy scripts are run in the same context.
    • PrashantS's avatar
      PrashantS
      New Contributor

      Thanks for the response Rao !

       The data I want to access is object and not string type. In one step(say Step 1) I am initializing the report object and then running another step(say Step 2) from Step 1. I want the report object from step 1 to be somehow accessible in step 2.

       

      One more thing, What if Step 1 and Step 2 are in different test suites?

      • nmrao's avatar
        nmrao
        Champion Level 3
        Object is accessible only "the same context" i.e.,If you run the project, then it is possible to access the object in another script. If step1 and step2 are run separately, then you would get null.