Forum Discussion

Jacob_Hassing's avatar
Jacob_Hassing
Contributor
16 years ago

Global datagen

maybe it is already possible ?
but i would like generate data which which would be available for all test cases in all test suites.
global properties available in all suites.

The persist series between test runs, should also work across suites.

1 Reply

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


    Since you're mentioning global properties and data generation in the same sentence, I assume you want to be able to (dynamically) generate data in a single place which can be consumed throughout your test project (and all test suites in it and test cases inside of them).

    Probably the best way to achieve what you're after is using a static method implemented in Groovy script. Let's say you would declare class, let's give it a nice name like DataGenerator, and one of the corresponding static methods, say generateIntArray(arrayLength). You would then need to pack the Groovy file inside either a Groovy script library or JAR file.

    After you have done all this, you will be able to access this dynamically loaded property from your test cases using dynamic property expansion:

    ${=com.example.utils.DataGenerator.generateIntArray(100)}


    If you wish to reuse your dynamically generated data you would need to persist it in some way. Groovy offers many ways to implement persistence, not necessarily relying on Groovy internal classes only, i.e. you can use Java persistence implementations too.

    I hope that this helps.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla