Using different configuration files for each workstation

When testing on several different computers, there sometimes arises a necessity to use various testing data or parameters. It may depend on the version of the operational system, its bit-rate, or it can even be different for every computer.

The simplest method to use different testing data in such cases is having data sets for each particular case—each time reading the data from the appropriate file.

Getting ready

Let's suppose, we have a file settings.ini, that contains all the preset parameters for the tests, to be declared in the code as follows:

var file = "settings.ini";
// code for settings read

At the point of launching tests on various operational systems, it turned out that each OS requires different settings.

How to do it...

To read supply settings from different files depending on the OS version, it is necessary to perform the following steps:

  1. Make several copies of the settings.ini file with the following names: WinXP.ini, WinVista.ini, Win7.ini, and Win8.ini.
  2. Write parameters in each file that are necessary for the eponymous OS.
  3. Change the code for the variable declaration in the following manner:
    var file = Sys.OSInfo.Name + ".ini";
  4. Now, the settings will be read from different files, depending on the Windows version used to launch and run the scripts.

How it works...

The OSInfo.Name parameter returns a short name of the current operational system. The unbridged name of the OS is possible to obtain from the OSInfo.FullName property.

Similarly, it is possible to organize reading the data for other cases of the kind. For example, if the data differs for every computer, the file names can be given by computer name, while variables could be created via the Sys.HostName property.

In case of the Data-driven Testing (DDT) approach, it is possible to store the data for different operational systems on different pages of the document, each corresponding to the proper operating system.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.93.175