Scope of Variables

Ask general questions here.
brentmclauclan
Certified Professional
Certified Professional
Posts: 23
Joined: Wed Jun 25, 2014 11:59 am

Scope of Variables

Post by brentmclauclan » Tue Jul 08, 2014 12:12 pm

Hi there.

I think this is the scope of variables within a Ranorex Solution...but I just want to be sure.

1. A variable created within a test case's recording module or user code module is local to that module and its value not available to other recording modules/user code created within the same test case.

2. A repository variable can be accessed project wide - through data binding and or by code.

3. In order to allow variables a more "global scope" then must be bound to a Global Parameter declared at the Test Suite Level. Once that is done the initial default value of the Global Parameter can be read or modified by any module level variables that are bound to it.

Please correct if I'm off track here.

Thanks

Brent

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Scope of Variables

Post by krstcs » Tue Jul 08, 2014 1:21 pm

Your analysis seems to be sound. Ranorex relies on .NET scoping since it is built on .NET.

I would add that you can add "public static" variables to any user code area (including Program.cs) and those values can be accessed by any other object at any time during the execution. But, as with any other type of globally scoped entity, since they are public they can be manipulated by anything, possibly in ways that you didn't intend, so use them with caution.
Shortcuts usually aren't...