Variables
Managing environment variables in CAT Studio.
On this page
First, to even see Variables page, you need to go to Settings page in CAT Studio and enable usage of variables:
Introduction
CAT supports usage of environment variables in its configuration files. They are supported in data source definitions and in test definitions, in value of any property.
Example: When you define environment variable CAT_MyProject_MyVariableName
, you can use %CAT_MyProject_MyVariableName%
in any property of data source definition or test definition and CAT will automatically pick up its value.
This is useful in more use-cases:
-
you want to hide secrets (password, entire connection string)
-
you want to parametrize your queries (e.g., run the tests for specific subsidiary or business event)
-
you use CI/CD pipelines and want to use same definition files for local running and for pipelines.
Very important!
We are talking about Environment Variables here. These are NOT project-specific or CAT-specific variables. They are saved in your operating system and are valid either for your account or for entire machine (depending on scope you set).
Manage Variables
CAT provides you a simple interface for managing your accounts/system environment variables. The variables page looks like this:
You can see and manage your environment variables on this page. CAT by default does NOT display all of them - you need to type at least three characters into Filter field and click “Filter Variables” button. Also, if the variable’s name contains “token”, “password”, “pwd”, “connection” or “secret”, its value in the grid is masked with stars.
To open environment variable editor dialog, double click it or use the edit button that appears on hover.
You can add/edit/delete system environment variables only when you run CAT Studio as Administrator.
Using Environment Variables
Use variables anywhere you like. Note that some controls in CAT Studio does not allow to add texts, such as spinners or dropdowns:
In that case, you need to use the button next to it. A dialog where you can put the variable appears:
When applied, CAT Studio checks the current value of the environment variable and uses it in the editor. When environment variable is used, the editor is read only. You can use rubber button to stop using the variable in the editor:
Note that in text-boxes the environment variable can appear as part of the value - or even more environment variables can be used for a single field.
When you type %NAME_OF_ANY_EXISTING_ENVIRONMENT_VARIABLE% anywhere in a text input (e.g., in password), CAT will automatically detect it and make the field read-only. The “Let me use environment variables” setting on Settings page controls whether you see the variable management interface and dialogs, but the actual variable usage works regardless of this setting.