Using global parameters across test suites

Ranorex Spy, Recorder, and Studio.
cpalex
Posts: 23
Joined: Sat Feb 17, 2018 12:37 am

Using global parameters across test suites

Post by cpalex » Tue Jan 22, 2019 3:45 pm

I am working on a rather large AUT, and have split my regression suite across multiple test suites in a single project.

There are some variables that I would like to use between all of the tests suites, such as username, or version number.

Is it possible to set a global parameter in a single place, and have it shared between the multiple test suites?

User avatar
Stub
Posts: 270
Joined: Fri Jul 15, 2016 1:35 pm

Re: Using global parameters across test suites

Post by Stub » Wed Jan 23, 2019 8:57 am

That's something I've started doing too - multiple Test Suites - and have a similar problem with duplicated parameters. "Truly Global Parameters" sounds like a good idea, one for the Ranorex UserVoice perhaps? I'd vote for it.

cpalex
Posts: 23
Joined: Sat Feb 17, 2018 12:37 am

Re: Using global parameters across test suites

Post by cpalex » Wed Jan 23, 2019 8:24 pm


cpalex
Posts: 23
Joined: Sat Feb 17, 2018 12:37 am

Re: Using global parameters across test suites

Post by cpalex » Tue Feb 12, 2019 5:27 pm

So, until that becomes a feature.... Is there a way I can do this programatically? We have a rather large AUT, and I'd like to be able to break the sections into different suites, and use just a single set of variables.

cpalex
Posts: 23
Joined: Sat Feb 17, 2018 12:37 am

Re: Using global parameters across test suites

Post by cpalex » Tue Mar 12, 2019 4:22 pm

For those interested, I came up with a simple solution

First, I create a simple class file, I called it GlobalParameters.cs, that just looks like this:

Code: Select all

using System;

namespace MyTest
{
	public class GlobalParameters
	{		
		public static string Version = "88.54.0.1";
	}
}	
Then, I created a user code module to set the parameter. I insert a module variable called "Version", and then in the run section, just add this:

Code: Select all

Version = GlobalParameters.Version;
Now, all I have to do is create a global parameter in the test suite I am working on, add the user code to the setup for the whole suite, and bind the variable in the user code module to the global parameter for Version.

Now, the parameter will be given the value in the GlobalParameters file, and I can change it in that file to affect all of my test suites.

loonquawl
Posts: 69
Joined: Wed Nov 22, 2017 10:08 am

Re: Using global parameters across test suites

Post by loonquawl » Fri Mar 22, 2019 4:06 pm

That is a very nice solution! Could you put it in the how-to section of the Forum?