A way to specify repeat through global parameter?

Ask general questions here.
User avatar
Gunner1980
Posts: 89
Joined: Mon Apr 05, 2010 8:44 pm
Location: Austin, Texas

A way to specify repeat through global parameter?

Post by Gunner1980 » Thu Apr 14, 2011 10:47 pm

I would like the repeat count to be set to a global parameter which the user can change when they run the test. I used to do this through user code using the following:

Code: Select all

      try
           {           					    	   	
    			int x = 0;
    			int y = Int32.Parse(Link_16_Regression.program.Count);
    			
           	   	while (x < y)
           	   	{
            	//Run Create Track Recording
            	TacViewLib.LinkSpecific.Surveillance.Air.CreateTrack.CreateTrackRegression.Start();
                   			
            	//Run Validate Track Recording
            	TacViewLib.LinkSpecific.Surveillance.Air.ValidateTrack.ValidateTrackRegression.Start();
                     	   	
            	x++;
           	   	}
           }
However now if I use this same code I won't see the recordings under the test case in the test suite nor do I know how to link a code module and a global parameter.

Any ideas on how I can do this? For now I have hard coded the repeat to 10 times in each recording but I really need to make it dynamic.

And actually being able to set the test case repeat instead of the individual recording would work best for me as I have two recordings in each test case.

I actually have one recording that creates something and a second recording that validates the data. I actually want those in one test case and want the test case to loop however many times.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: A way to specify repeat through global parameter?

Post by Support Team » Thu Apr 14, 2011 11:59 pm

Hi,

TestCases can be repeated using tables. A one column table can be associated with the test case then this testcase will be played as many times as there are rows in the table. There is no need to map to a variable.

If you want to provide the repeat via a global parameter here is a rather ugly kludge. But I have also made a feature request for this.
  • make a global parameter called "repeats"
  • the format of this "repeats" to fit with the below code must be "TestCaseName_3" (TestCaseName is any TC, 3 could be any number)
  • make a test case and call it "runs_another_testcase_with_global_param_repeats" or better "ratwgpr"
  • drag a user code module containing the following code into the TC
  • map the "repeats" global parameter to the "repeats" variable of the user code module
  • command line should then be:

    Code: Select all

    Your.exe /tc:ratwgpr /param:repeats=YourTestCase_4
Hiere is the user code:
string _repeats = "1";
        [TestVariable("6F25EE5C-F8B8-4553-8EC3-0AA05AF1B434")]
        public string repeats
        {
        	get { return _repeats; }
        	set { _repeats = value; }
        }
		void ITestModule.Run()
        {
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;
			
            string[] tc_rep= repeats.Split(new char[]{'_'});
            string testcasename = tc_rep[0];
            int repcount = Convert.ToInt32(tc_rep[1]);
            while (repcount-- > 0)
            	Ranorex.Core.Testing.TestSuiteRunner.Run(typeof(testRepository),"/testcase:"+testcasename);
        }
Regards,
Roland
Ranorex Support Team

User avatar
Gunner1980
Posts: 89
Joined: Mon Apr 05, 2010 8:44 pm
Location: Austin, Texas

Re: A way to specify repeat through global parameter?

Post by Gunner1980 » Fri Apr 15, 2011 3:48 pm

I will try out your kludge code and let you know if it worked.

The reason I don't want to use a table is because what I am doing in this particular test case is picking random values and then looping it a certain number of times. Unfortunately for me to go through every value in this particular test case it would take 8 hours to run or longer. I do not have time to do this on our daily builds so instead I use code that picks random drop down items. I only run the full regression every month or so. I also don't want the same values tested every test run.

Basically I have 20 or so fields, which I pick a random drop down item for, I then store the item that was picked to a variable, I then validate that the value entered was what was received on another GUI which the data was transmitted to.