Modified coded modules and Variables used

Class library usage, coding and language questions.
User avatar
Naplespoet
Certified Professional
Certified Professional
Posts: 9
Joined: Fri May 20, 2016 6:12 am

Modified coded modules and Variables used

Post by Naplespoet » Thu Apr 26, 2018 4:42 pm

Ok have a question, we are small shop and im learning the customization of coded modules so every time we created a new coded module test we dont have to keep typing some of the repetative things like Usings or if every test uses Like first line host.local.OpenBrowser , we modify the default for a coded module so we can get to the fun stuff quicker... so in that we always have some of the same var on new tests as we are bulding like the one below to set the test domain etc. now would this cause a problem If i put this in a custom coded module file, as I am not aware of what that number identifier does or if it would affect it if multiple test contain the same one below, could i use the same one across tests to save time and having to add it each time?
not sure if im explaining it correctly. but in short , we use modified coded module files for our default when "adding a new coded module" could i potentially set the same for Variables we use on all our tests and just set it once so we dont have to keep adding it? thanks in advanced.

string _testDomain = "localhost";
[TestVariable("748104c8-60e2-4647-9dc9-10ae1434169f")]
public string testDomain
{
get { return _testDomain; }
set { _testDomain = value; }
}

qwertzu
Posts: 178
Joined: Wed Jan 25, 2017 11:08 am

Re: Modified coded modules and Variables used

Post by qwertzu » Mon Apr 30, 2018 10:19 am

Hi,
Generally spoken, I would recommend (and that's what Ranorex guys also do) not using code as long as it is not really necessary. The concept of the Ranorex repository and the recording modules help you keep a test organized and adaptive.
Also for your exact approach, using the Ranorex GUI would help.
You can simply create a global parameter called "localhost" which can be accessed in every module of your whole test.
You can change the value of this parameter before starting the test, or even during runtime using the following codeline:

Code: Select all

TestStuie.Current.Parameters["<PARAMETERNAME>"]="NewValue"
regards, qwertzu

User avatar
Naplespoet
Certified Professional
Certified Professional
Posts: 9
Joined: Fri May 20, 2016 6:12 am

Re: Modified coded modules and Variables used

Post by Naplespoet » Mon Apr 30, 2018 2:06 pm

I understand the using of the global param. which i have already set, but lets say im creating module based tests all independent from each other and everytime I add a new coded module to write tests I have to add a new variable, but since we customize our coded modules , to include any usings etc that we always repeat we want to cut down on repetitive tasks. essentially the question is if have this variable below with that number , could i just use it across tests the same. its not about using the same value im literally asking about the variable with the test variable number is there any issue if i just use the same one with same number across all tests.

so test 1 would have ::
string _testDomain = "localhost";
[TestVariable("748104c8-60e2-4647-9dc9-10ae1434169f")]
public string testDomain
{
get { return _testDomain; }
set { _testDomain = value; }
}

test 2 would have

string _testDomain = "localhost";
[TestVariable("748104c8-60e2-4647-9dc9-10ae1434169f")]
public string testDomain
{
get { return _testDomain; }
set { _testDomain = value; }
}