159. Parameterization of test data







What is a Parameter ?

A parameter is a special kind of variable. A parameter type variable is used in methods/functions to refer to the data that is passed as arguments to the methods/functions.

Example in Java Programming Language:

Method/Function containing Parameters:

public void add(int a, int b)
{
    System.out.println("The value of the parameter a is "+a);
    System.out.println("The value of the parameter b is "+b);
}

Calling the above method or function to pass the data as arguments:

add(5,6);

Output of this Program:

The value of the parameter a is 5
The value of the parameter b is 6

After looking at this example, its very clear that the values in the method call i.e. 5 and 6 are nothing but the data to be passed to the Method or Function. So these data is technically called as arguments. This arguments when passed to the Method/Function will be assigned to the parameter variables of the method/function i.e. integer variables a and b in this example. So finally we use these parameter variables in the method/function to represent the argument values that are passed to the method. Hence on printing a and b parameter variables inside the above method/function , the argument values 5 and 6 get printed.

What is Parameterization ?

Parameterization is the process of replacing the values inside the methods with parameter variables. We will pass the replaced values from an external file to the respective parameter variables in the method.

Hence in Test Automation code, Parameterization concept is used to replace the test data in methods with parameter variables and the replaced test data is then passed from an external file to the respective parameters in methods as arguments.

Naming Convention for Parameters 

As we already know that we've to use the following naming conventions for Class names and Method names:

Class naming conventions:

  • Should start with Capital Letter
  • If the Class Name contains Two words, we've to start all the words with a Capital letter
  • Remaining Letters in the words need to be in small.
Examples for Class Naming Conventions:
  • Facebook
  • FacebookFriends
  • FacebookPrivateGroups
Method naming convention:
  • Should start with a small letter
  • If the Method Name contains more than one words, we've to start all the words except the first word with a Capital letter
  • Remaining Letters in the words need to be in small.
Examples for Method Naming Conventions:
  • facebook
  • facebookFriends
  • facebookPrivateGroups
In the similar manner we've to use the following naming conventions for Parameters:

Parameter naming convention:
  • All the Letters should be in Capital
  • If the Parameter Name contains more than one words, we've to separate all the words with underscore (i.e. _ )
Examples for Class Naming Conventions:
  • FACEBOOK
  • FACEBOOK_FRIENDS
  • FACEBOOK_PRIVATE_GROUPS


Please comment below to feedback or ask questions.

Parameterization with testng configuration file will be explained in the next post.






No comments:

Post a Comment

Followers

Labels