Feature Keyword in Cucumber Framework
In the Cucumber framework, the Feature
keyword is used to define a high-level business requirement that the application must fulfill. It represents the functionality that will be tested and consists of one or more Scenarios written in Gherkin syntax.
Syntax of Feature Keyword
Feature: <Feature Name>
Description: <Brief explanation of the feature>
Scenario: <Scenario Name>
Given <Precondition>
When <Action>
Then <Expected Result>
Description: <Brief explanation of the feature>
Scenario: <Scenario Name>
Given <Precondition>
When <Action>
Then <Expected Result>
===========================================================
Example 1: User Login Feature
Feature: User Login Functionality
As a registered user
I want to log in to the application
So that I can access my account
Scenario: Successful Login
Given the user is on the login page
When the user enters a valid username and password
And clicks on the login button
Then the user should be redirected to the homepage
Explanation:
- The Feature describes the login functionality.
- The Scenario specifies a test case for successful login.
- The Given, When, And, Then steps define the test flow.
===========================================================