TABLE OF CONTENTS
2. Construct a Meaningful Feature File
2.2 Provide Meaningful Feature Names
2.3 Provide Meaningful UI element Names
2.4 Provide Appropriate Parameters
2.5 Provide Appropriate Action Words
1. Overview
To produce meaningful Given-When-Then (GWT) steps, configure features and UI elements with clear and descriptive names. Use action words (default or custom actions) that describe user actions. Parameterize the UI element to reduce the number of test steps.
2. Construct a Meaningful Feature File
Consider a scenario where a new user is registering for an account on an Amazon website and has provided the phone number for OTP verification during registration process.
A system generated feature file is, as follows:
Let's consider the following example sentence in the previously generated Feature File:
'When I entered 'name' in the create account page as the <name>.' This sentence serves as a meaningful example of a GWT step.
The following table outlines the components used to generate meaningful GWT step, including the feature name, UI element name, action word, and placeholders (parameters):
Sequence number | Field Name | Description |
1 | create account page | This is the feature name where the user action takes place |
2 | name | This is the specific UI element name where user enters the username in the application |
3 | entered | This is the action word describing the user's input action |
4 | <name> | Placeholder (parameters) indicating where specific UI element values are substituted |
5 | example table | Displays the parameterization values for the 'name' UI element, such as Last name, First name |
2.2 Provide Meaningful Feature Names
In the example sentence, "When I entered name on the create account page as <name>," 'create account page' is the feature name which reads well in the sentence because, it states the action being performed (entering a name) and where it's being performed (on the create account page).
The 'Create account page' feature name identifies the specific part of the application being tested. It focuses on the action of creating an account and provides a clear context for the test scenario.
If you use 'registration process' as the feature name instead of create account page the focus shifts to the broader process of registration, which may encompass multiple steps and actions beyond just entering a name. It's less specific about the exact location or action being tested, which can make the scenario less precise.
Tip: Avoid creating duplicate feature names.
2.3 Provide Meaningful UI element Names
When you see "When I entered 'name' on the create account page as <name>," the word 'name' refers to the specific field where you type your information. For example, if you are creating an account and need to enter your actual name, you should type it into the 'name' field.
If you use "Enter Your Name" as the UI element name in the sentence, like "When I entered 'Enter Your Name' on the create account page as <name>," it can be confusing. This is because "Enter Your Name" sounds like instructions on what to type rather than indicating where to type your name.
2.4 Provide Appropriate Parameters
Parameters are variables or placeholders that can be used to pass information into a test step or suite of tests. Parameterization helps in reducing the length of a scenario.
Example without Parameters
For example, if you want to test a create an account process, and you need to check how it works with different names and passwords. If you don’t use parameters, each test case looks like this:
Test Case 1: Create an account for Alex Johnson
- When I entered name in the create account page as '<Alex Johnson>'
- And I entered mobile number in the create account page as '9878342101'
- And I entered password in the create account page as 'Password@123'
- And I selected verify mobile number in the create account page
- Then verify text 'create your account' in the create account page
- And 'current screen' is displayed with 'NA'
Test case 2: Create an account for Emily Davis
- When I entered name in the create account page as 'Emily Davis'
- And I entered mobile number in the create account page as '9876543210'
- And I entered password in the create account page as 'Password456'
- And I selected verify mobile number in the create account page
- Then verify text 'create your account' in the create account page
- And 'current screen' is displayed with 'NA'
Each time you want to test a new name or password, you have to create a new test case. This becomes repetitive and time-consuming which increases the test step length.
Example with parameters
Instead of creating a new test case for each name and password, you can use parameters to set up a single, reusable test, which reduces the test steps length.
Test case 2: Create an account for <name>
- When I entered name in the create account page as '<name>'
- And I entered mobile number in the create account page as '<mobile number>'
- And I entered password in the create account page as '<password>'
- And I selected verify mobile number in the create account page
- Then verify text 'create your account' in the create account page
- And 'current screen' is displayed with 'NA'
Adding parameters
In the Node Configuration, when you are providing UI element name, make sure to provide the necessary parameters in the 'Control Value' text box. Parameterizable UI elements include Text Box, Dropdown list, Text Area, Scroll, Window and New Tab . You can define these parameters in the 'Control Value' text box to specify input variations, as shown:
By adding parameters, you create placeholders for specific user input values, as seen in the GWT step:
The user's input values in these placeholders reflect in the example table as follows:
2.5 Provide Appropriate Action Words
In the example sentence, "When I entered name on the create account page as <name>", 'entered' is the action word.
The action word ' entered' describes the action being performed by the user, which is typing a name into a specific field on the create account page. Ensure to maintain consistency in the use of past tense while using action words. Action words depend on the UI element type selected.
If you use "selected" instead of "entered" for a text box:
Incorrect Action: "When I selected name in create account page as <name>."
In this sentence, "selected" is misleading because you are not choosing from a dropdown list; you are typing the name into a text box.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article