What is a feature in cucumber testing?
A feature is a functionality or standalone unit of a software application. In other words, the feature is a parameter which is used to test the requirements of the customer from the software product.
Let's understand it through a very common example of a social networking site.
Few basic features of the social networking site can be determined as -
At the time of testing, it is the best practice that we should determine the features first, before deriving the test scripts to be tested.
Hence from the above discussion, it is clear that, when we talk about cucumber, each independent functionality of the product or web application can be called as a feature. A feature typically has a list of scenarios to be tested for that feature, and the feature and its description are stored in the feature file.
There can be numerous features of a software product. Hence for the better management of features, we should create a separate feature file for each feature.
The keyword "Feature" represents a feature under the test in Gherkin language.
Note: It is recommended that write a small description of features beneath the keyword feature in the feature file.
Suppose, the feature login functionality of a social networking site is under the test. Hence, we need to test it as per the following aspects:
Now, we are going to create a feature file for the login feature of the social networking site:
Feature: Login functionality Scenario: Successful Login with Valid entries Given user navigates to the website facebook.com And user logs in through Login link by using username as "email@example.com" and password as "prity123sharma" Then login must be successful. Scenario: Unsuccessful Login with Invalid entries Given user navigates to the website facebook.com When username is incorrect, but the password is correct user logs in through Login link by using Username as "Parma321@yahoo.com" and Password as "prity123sharma" When username is correct, but the password is incorrect user logs in through Login link by using username as "firstname.lastname@example.org" and Password as "12345678" Then login must be unsuccessful.
According to the above example, we can create feature files as per the particular feature. A feature file is always based on the behavior of an application under specific circumstances.