Sudheer,
I’ve tried it as a test suite as well as separate test cases.
This seems like a pretty fundamental thing. I was hoping that it would be more intuitive to do. But, I wouldn’t be surprised if it’s just me not doing something right?
Russ,
I already had a look at that document but it appears to be that these global variables, declared in profile are static?
I want to be able to store values that are dynamic and change depending on the running of certain test cases. It would have been very easy for me to simply store that codeID as ‘31065’, but this can change when I run TC1.
The final modifier indicates that the value of this field cannot change.
In Katalon Studio, a GlobalVariable is declared as static but not as final. You can find the source code of GlobalVariables in the default Execution Profile at <projectDir>/Libs/internal/GlobalVariable.groovy. The following snippet is an example of GlobalVariable source:
Provided with the above GlobalVariable.Hostname, my Test Case A can set a value, and Test Case B can read the value; B sets a new value and C reads the value — if all of the A, B, C runs in a Test Suite S.
HI kazurayam, I am trying to set a globalvariable value in default profile from running a test case (B) day 1, then come back the next day and run 2nd test case (C) to read value. I tested your exact code sample above for Test Case B+C (I figured i could skip A since B ‘sets’ the value too)
However this did not work, Test Case B does not save globalvariable value in the profile. Am I missing something?
A GlobalVariable is scoped within a TestSuite. You make a TestSuite S which includes TestCase A and TestCase B. TestCase A updates a GlobalVariable and TestCase B reads the GlobalVariable. And you execute the TestSuite S; TestCase A and B will be executed in a sequence having no time gap in between. Then TestCase B can read the value on memory set by TestCase A. The value updated into a GlobalVariable will never be persisted into a file.
If you need days in between TestCase B and C, then a GlobalVariable is not a good vehicle for your data. TestCase B needs to write the data into a file, and TestCase C reads data from the file. Katalon Studio does not provide a ready-made tool for persisting custom data. A practical way for you would just develop a Groovy code to write/read a JSON file.
thanks for quick response. It does appear to work in a test suite. after suite completes the variable no longer persists, but thats fine as long as works in a suite. I will use the write to file scenario.