# Getting the list of test case variables, from a Test Case, programmatically

**URL:** <https://forum.katalon.com/t/getting-the-list-of-test-case-variables-from-a-test-case-programmatically/104222>\
**Category:** Web Testing\
**Tags:** test-case-variables, katalon-studio\
**Created:** [November 10, 2023, 4:17am UTC](https://forum.katalon.com/t/getting-the-list-of-test-case-variables-from-a-test-case-programmatically/104222 "2023-11-10T04:17:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwarren04011990](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mwarren04011990/32/26024_2.png) [@mwarren04011990](https://forum.katalon.com/u/mwarren04011990)\
**Post date:** [November 10, 2023, 4:17am UTC](https://forum.katalon.com/t/getting-the-list-of-test-case-variables-from-a-test-case-programmatically/104222/1 "2023-11-10T04:17:46Z")

</div>

## Problem

Let’s say that you are testing a part of a system, that requires the test case to happen in multiple parts. For example, in my job, I have a test case that require me to:

- create a test medical practice, complete with members
- wait several days to pay invoices of all members
- wait some more days to check pay out to the physician

You create the steps for the test cases, but then how do you remind yourself/fellow test devs to run the test case for the next step? You have two real options:

- create Google Calendar event (or something similar) for the task manually, or…
- create that same Google Calendar event _programmatically_

This is good, however, what to do if your test case steps have **variables**? For example, what if they take `npiNumber`s, `practiceProfile`s, … , that you(r fellow test devs) need to run and validate the test case results? How do you get those programmatically?

## Solution

Every Test Case `Script` has `Binding`, which then has `Map<String, Object> variables`. Hence, you could just say, in the Test Case itself:

```auto
this.binding.variables

```

to get the dictionary of test case variables. This will, as of the time of this post, **only get the Test Case Variables**!

## Testing it out

Let’s create a Test Case, call it `Test Case Variables`, with the following test case variables:

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/2/2/2296c18cfb43d2b7464293019d58d6e6641349d1.png)

Let’s then implement that test case to be:

```auto
import com.signaturemd.models.practice.PracticeModel

import groovy.transform.Field

final String tmpVar = "temp variable"

PracticeModel model = new PracticeModel()

@Field
String field = "field variable"

assert this.binding.variables == [ 
	('a') : 0,
	('b') : 1,
]

```

Run it, and you should see that this **test case passes**.

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [November 10, 2023, 6:05am UTC](https://forum.katalon.com/t/getting-the-list-of-test-case-variables-from-a-test-case-programmatically/104222/2 "2023-11-10T06:05:32Z")

</div>

Thank you for such a great sharing. Keep going @mwarren04011990
