Page 1 of 1

Global variable for all test projects

Posted: Fri Mar 06, 2020 7:31 pm
by theraviz
Hi,

As per my understanding global variables can be defined at test suite level. Is there a way to declare a global variable so that it can be accessed across all projects in a solution?

Re: Global variable for all test projects

Posted: Mon Mar 09, 2020 8:40 am
by odklizec
Hi,

As long as the individual project files are a part of the same TestSuite, you can bind them to Global Parameters, no mater to which project they belong to. In other words, files (recordings and code modules) from different Projects, could be binded to the same Global Parameters. Just add them to Test Suite of your choice.

Re: Global variable for all test projects

Posted: Mon Mar 09, 2020 8:58 am
by Stub
My initial take on this was sharing the global variable across multiple test suites, but I'm unclear if that's a correct interpretation?

I know that my test solution has a test project with multiple test suites, and I have a few variables common to each test suite for consistency and ease of use.

Re: Global variable for all test projects

Posted: Mon Mar 09, 2020 9:14 am
by odklizec
Hi Stub,

Yeah, I too considered he means sharing variables between test suites? But as he specifically mentioned "projects", I answered "project files in the same test suite". We will see from his response ;)

Re: Global variable for all test projects

Posted: Mon Mar 09, 2020 12:32 pm
by theraviz
[/quote]
odklizec wrote:
Mon Mar 09, 2020 9:14 am
Hi Stub,

Yeah, I too considered he means sharing variables between test suites? But as he specifically mentioned "projects", I answered "project files in the same test suite". We will see from his response ;)
Hi Odklizec,

Below is my project structure. As you see I have Project 1, 2 and 3. Now I need to define a global variable so that the recordings of my Test Suite A,B and C can access the same variable.

Ranorex Project.JPG

Now When we open the Global parameter Window from any recording accross the project I need to have my global parameter appearing there. In the below screenshot the variable is only accessible for Test Suite A. I need to know a place where I can define the same which can be accessed across all recordings in the whole solution.
Ranorex Project.JPG

Re: Global variable for all test projects

Posted: Mon Mar 09, 2020 3:29 pm
by Stub
I don't know of a super-global variable list that is common across multiple Test Suites.

All of our Test Suites share the odd variable, but each is individual to that Test Suite. Our build system informs the Test Suite what the value is for that variable when it executes the tests in a Test Suite. I tweak them manually when I'm running from Ranorex Studio during test development.

You might define the variable value in code somewhere, and then have a Code Module which updates the Test Suite global parameter list when the tests run. Thus all Test Suites share the one value. Very awkward though.

Re: Global variable for all test projects

Posted: Mon Mar 09, 2020 3:55 pm
by N612
I personally would use a centralized data source and update the global parameter with the data source value at the start of each test suite. The below screenshots and attached 9.3 solution may help with achieving this in your solution if you do go this route.