Parametrization is the process in which you replace hard-coded values in Action logic with symbolic variables. Instead of using actual literal values in the logic, you define and use a placeholder. This approach promotes modularity and reusability by allowing the same Action to be used with multiple variations of inputs (data-driven testing).
A Statement is the basic building block in Action logic. Each statement accomplishes a certain interaction, verification, or other tasks on the test application.
Depending on the nature of the Statement, you may need to furnish additional information to it. For example, if your Statement is to type some text in an input field, you will need to provide the following information.
- What text do you want to enter? (text to enter)
- In which field do you want to enter the text? (field name)
Consider the example below. This is the logic for logging onto QBank.
In this example, username and password (encrypted) are hard-coded in the first two Statements' Action logic. The same set of usernames and passwords are used in any Scenario this Action is used.
Parameterization is the process where these hard-coded values are replaced with symbolic variables called Action Parameters so that different sets of usernames/passwords can be passed every time this Action is called.
Action Input Parameters
Input Parameters are placeholder variables used in Action logic. You can define multiple input parameters for a given Action.
Values for input parameters must be furnished from the place where this Action is called. Remember, an Action can be called either from a Scenario or from another Action.
Creating Input Parameter
- Open the Action.
- Click on the "Parameters" tab in the sidebar of the Action.
- Click "+" on the Input Parameter listing.
- Type a name and provide a brief description.
- Select if this is a mandatory input or not. If the parameter is not mandatory, a blank value is considered as valid input from a test case.
- Define restrictions on values that can be entered
How to use Action Parameter in Action Logic
To make use of an Action parameter, click the argument in the statement and open the "parameterization" options list. Choose "Action Parameter" and select one.
Alternatively, you can simply type the name of the parameter in the input box and ACCELQ provides suggestions to pick the parameter.
Specifying acceptable values for Input Parameters
When you define an Input Parameter, you can indicate if any restrictions should be placed on permissible values for this parameter. When you use this Action from a scenario, the user is guided to select one from the list of permissible values.
When the parameter allows freeform text as a value, you can choose to present it as encrypted text rather than plain text. This will directly encrypt the text when passing to the Action. Make sure the statement using such a parameter is designed to accept encrypted values.
There are two ways you can restrict the values. Either by pointing the input to a data list or a data type. Only the values/nodes available in the definition of data list/data type are allowed from the scenario.
In addition to providing guidance (of what values can be used) to the user while creating a Scenario, this feature greatly helps with automated test case generation.
Using Action Parameters as control variables in logic
Action Parameters need not always be for inputting Statement arguments. Sometimes, it may make sense to create Action parameters to control the behavior of Action logic. Consider the example below, where there is additional back-end validation performed on a given condition. Verify Purchase Order may be used in a lot of test cases and you may not always want to perform the back-end verification. Is Verify-in DB is an action input parameter that provides the ability to control an Action's behavior. When you define a test case, you pass Yes/No based on if DB validation is necessary or not.
Deciding which inputs to parameterize
While developing Action logic, there may be a need for multiple input values across statements. Parameterization is a powerful capability to make the Action reusable with multiple variations of input data. However, it is equally important to know that not all inputs should be parameterized.
Consider an Account creation Action for Salesforce implementation. There may be a large number of input fields required to create an account. But it is not recommended to parameterize every one of those inputs. For example, a "Description" field value can probably be hard-coded in the logic itself and you may not need to parameterize and test with different values for this field.
Too much parameterization can lead to overheads in maintenance and you make the test case creation process complex. When creating a Scenario, a user needs to think about a lot more input values. Optimize this by choosing to parameterize only those inputs that are functionally significant from a testing viewpoint.
Action parameterization for Reusability
In most situations, Actions are parameterized to support data-driven testing to exercise a Scenario with different combinations of inputs.
However, another equally important reason to parameterize is to promote reusability. Consider a situation where you have multiple well-defined menu items in the top nav of an application. Selecting a menu item may involve pressing the top link and choosing an option in the menu.
As part of your automation requirements, if you are required to have logic to select multiple such menus, it makes sense to parameterize the Action to select the menu options.
Action: Navigate to top menu item
Parameters: Top menu name, Menu item