Import/Export function for Test Case variables

Marek,

I think that a GlobalVariable of type java.util.Map would be useful for you.

I have made a project “KatalonDiscussion9854” to demonstrate my proposal. You can download the zip file from Releases page.

I would copy & paste the README here.
---------------------------

How to run the demo

  1. start your Katalon Studio, open this project
  2. please note that a Profile default defines a GlobalVariable named MEMORY of type java.util.Map.
  3. select Test Suites/TS0 and run it

Processing

  1. GlobalVariable.MEMORY is initialized with values: ['A':'a', 'B':'b', 'C':'c', 'D':'d', 'E':'e']
  2. Test Suite TS0 execute a series of test cases: TC1, TC2, TC3.
  3. Each test cases prints MEMORY, and update it.

Code

The source of test cases is very simple. For example, TC1 is as simple as this:

import internal.GlobalVariable as GlobalVariableMap memory = (Map)GlobalVariable.MEMORY
CustomKeywords.'my.MemoryManager.retrieve'(memory)  # retrieve memory
memory.put('A', "TC1 said hello")                 

Output

TC1 prints the MEMORY, as follows:

key=A,value=akey=B,value=b
key=C,value=c
key=D,value=d
key=E,value=e

TC2 prints the MEMORY, as follows:

key=A,value=TC1 said hellokey=B,value=b
key=C,value=c
key=D,value=d
key=E,value=e

TC3 prints the MEMORY, as follows:

key=A,value=TC1 said hellokey=B,value=TC2 said welcome
key=C,value=c
key=D,value=d
key=E,value=e

TC4 prints the MEMORY, as follows:

key=A,value=TC1 said hellokey=B,value=TC2 said welcome
key=C,value=TC3 said goodbye
key=D,value=d
key=E,value=e

Please note that the GlobalVariable.MEMORY is shared by test cases and updated mutually by them.

Conclusion

Each test cases declares a single variable Map memory which contains multiple key=value pairs. This reduces need to type variable names repeatedly in each test cases.

5 Likes