Forum Discussion

Jourdelune's avatar
Jourdelune
New Contributor
16 years ago

Global Datagen

I want to use a unique ID based on a TimeStamp.

I got the idea of the GroovyScript and how to inject the TimeStamp in my SOAP Request. (it work fine)

Is there a way, to define at 1 place the Datagen - GroovyScript to get the TimeStamp and use that for different Test Suites?

It would be a blast to make that Datagen global to all project.

Jourdelune

22 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Jourdelune,


    You can achieve globally available functionality implemented using Groovy. Place your Groovy script in SOAP_HOME/scripts folder and use static methods like this:

    class IdGen
    {
      def  getId() {
      // ... your timestamp-based id generating code
      }
    }


    After you restart soapUI it will load these global Groovy scripts and your new methods will be available for use like this:

    newId = IdGen.getId()


    I hope that fills your need.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla
    • sharmameera's avatar
      sharmameera
      Contributor

      I do not have the SOAP_HOME folder where my SoapUI is installed. Instead I have the C:\Program Files\SmartBear\SoapUI-Pro-5.1.2\bin\scripts path.

      But even when I place my script there, with the groovy extension and then restart SoapUI, I am unable to use that script. I get the Unable to resolve class (and class name) error.

      • NiclasReimertz's avatar
        NiclasReimertz
        Staff

        Ouch!

         

        I think this is due to us moving to new forums. This topic used to be in the pro forum.

         

        The feature you've been trying to use is in Pro only, that's why it's not working :smileysad:

         

        If you look at the following page in the documenation: http://www.soapui.org/scripting---properties/scripting-and-the-script-library.html, you'll see that it's Pro Only:

         

        "Now let's setup SoapUI Pro to load up your Groovy library. Set File > Preferences > SoapUI Pro tab > Script Library. So I would set that to "C:\GroovyLib" in my example. Then restart SoapUI Pro to pick up the library script."

         

        And just to explain nomenclature, by SOAP_HOME we mean where soapUI is installed. In your case e C:\Program Files\SmartBear\SoapUI-Pro-5.1.2\.

         

        Sorry about the bad news...

         

        /niclas