# Import/Export function for Test Case variables

**URL:** <https://forum.katalon.com/t/import-export-function-for-test-case-variables/13416>\
**Category:** Feature Request\
**Tags:** feature-request, katalon-studio\
**Created:** [September 26, 2018, 3:27pm UTC](https://forum.katalon.com/t/import-export-function-for-test-case-variables/13416 "2018-09-26T15:27:28Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [September 28, 2018, 1:21am UTC](https://forum.katalon.com/t/import-export-function-for-test-case-variables/13416/3 "2018-09-28T01:21:30Z")

</div>

Marek,

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

I have made a project “[KatalonDiscussion9854](https://github.com/kazurayam/KatalonDiscussion9854)” to demonstrate my proposal. You can download the zip file from [Releases](https://github.com/kazurayam/KatalonDiscussion9854/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:

```auto
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:

```auto
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:

```auto
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:

```auto
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:

```auto
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.

---

_[View the full topic](https://forum.katalon.com/t/import-export-function-for-test-case-variables/13416)._
