Forum Discussion

Keacey's avatar
Keacey
Contributor
17 years ago

global variables between suite and test case

Hi,

i want to declare some groovy variables at the beginning of the suite (suite set up script) and update these values at the end of every test case (test case tear down) and then finally use these variables at the end of test suite (suite tear down).

How can i do this? Since, when i an declaring a variable in suite set up script, i can only access it with it the same script.

Thanks in advance.
KC.
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    Try using the TestSuite properties for this, you can access them from within your scripts with something like

    testRunner.testCase.testSuite.properties["property-name"].value =

    regards,

    /Ole
    eviware.com
  • Hi,

    I was looking more like global variables rather than properties.
    for example,

    in test suite set up script i have
    def a=0

    i must be able to access the variable "a" from a test case script, something like perform the function

    def b = a + 5

    so for this i must be able to access "a" from the test case.

    Please tell me how i can do this.

    Thanks in advance.
    KC.
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    currently, properties is the easiest way to do this;

    1) define your properties at the TestSuite level

    2) initialize them in the TestSuite setup script:

    testSuite.properties["..."].value = ..

    3) read/write them in your TestCase/TestStep scripts:

    def a = testRunner.testCase.testSuite.properties["..."].value

    Does that work ok?

    regards!

    /Ole
    eviware.com