Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
Problem Statement:

When developing an automation framework using Test Partner, we sometimes come across situations where we need the framework to be more generic in nature. Usually we develop many scripts and we call all the scripts inside one main script. Sometimes we may need to run only a particular set of them. For doing this we need to go to the main script and comment all the scripts which we don’t want to run. However this approach is not a good one and can be handled in a better way so the framework enables us to decide which test scripts should run and which should not when we are calling a number of test scripts inside a main script.

Solution

Below are a few examples which demonstrate an idea for achieving the same. Suppose we have developed few scripts in Test Partner and we are calling all of the scripts in a single main script as shown below:



Now there can be a case where I want to run only a particular script when I call this main script. We have the option of going to this main script and commenting out the scripts which we do not want to run. But that is not a good generic framework. Using this type of approach will always lead me going to the code and commenting and uncommenting the scripts.

We can solve this problem by using INI Files which are the same as Notepad Files and they have an extension .ini. An INI file usually has 3 components i.e. Section, Entry and Value.
The Contents of a sample INI File are shown below:



The above displayed INI File has two Sections namely IH and MM. Each section IH and MM has Entries and each of these entries are assigned a value.

[IH]: This is called Section

IH_InstRem_DefinedSearch: These are the entries in the Section [IH]

1 or 0: These are the values corresponding to the entries. In the above example the value is 1.

After entering all the details in the INI File we can use a API called GetPrivateProfileString and write a function which then reads values from the INI Files. In each of the test cases we first check the value of its entry in the INI File. If the value in the INI File is 0 then the test case is not run; else allow the test case to run.

The API used is:



The Function which can be used to read values from INI Files is:



The parameters passed in the above function are described below:

InFile$: Path of the INI File where entries are to be read.

Section$: Section in the INI File from where to read entries.

Entry$: Entry in section mentioned above for which the value has to be read.

In each of the scripts we can have a Function at the beginning which calls ReadIniFormat and returns the value assigned to Entries. If the value returned is 0 then we can exit from execution of that script, else we can continue its execution. In this way it would be very easy for someone to run test cases based on need.