Import/Export function for Test Case variables

Hi Team,

I would like to ask if feature for importing/exporting Variables within Test Case tab is planned, or if is it possible to suggest this. Having a lot of Test Cases and typing variables for each one requires to type it repeatedly. Eg. in concurrent tool SOAP UI there is a possibility to store variables to file and import.

Thank you in advance

Kind Regards,
Marek Henzl

5 Likes

This is a transversal problem. It would be very usefull to improve the copy/paste functionality between two Variables tabs, between two Profiles, between two Data Files, between two Data Bindings, etc.

1 Like

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

Also you can make a test case variable of type java.util.Map.

This would be useful for reducing variable names in test cases as well.

Map_as_testcase_variable.PNG

3 Likes

50 * Upvoted for the initial feature request!

I started a new project where I will splitt the workflow in independent parts of “dummy test cases”, as I currently like the CallTestCase feature approach.

Those dummy TC are called depending on the test path by the real test cases.

Currently it is a pain as I have created 5 workflow parts (dummy TC) and 3 test cases. All needs to set the variables tab with 15 entires of type Map.

I will cry if I have to add the other 10 dummy test cases and 20 test cases.

1 * upvoted for kazurayam code example.

The work around by kazurayam seems to be good, but I belive that Katalon sould support this by a build-in feature.

If everybody needs to write his own code to get around a lack of a missing feature, it will end in a tool which looks and works different for everyone.

As less as possible CustomKeywords are required to have a better common tool.

This feature request has been acknowledged and handled with the following solution: https://github.com/katalon-studio/katalon-studio/issues/12.
Please follow up its implementation status there.