Feature

Imagine "features" in Cucumber as individual stories that describe what a software should do. These stories are written in a way that everyone whether they write code or not can easily understand.


Features act like a blueprint for testing. They're understandable documents that explain what the software should do. Developers use them to write code that matches these expectations, and testers use them to check if the software behaves as expected.


Features are the starting point for discussions, coding, and testing in Cucumber. They're written in a way that everyone involved in the software development process can understand and use as a guide to make sure the software works just right.


Let's understand this by an example

Assume that following image is a home page of a website having a single static page. They have some content about their service and at the bottom a contact number to contact for their service.


demo-website-1

Now the business team decided to add a new functionality or feature to their website so that the customers can request a call back by submitting a form.


After discussion with the development team and testing team they decided to add a page in this website having a link in home page as Request Call.


Now this piece of functionality become a new feature to the website. The business team drafted a requirement summary and shared with the entire team. The content of the requirement document is as follows:


As a user I should be able to enter my contact number and short description in the request call form and submit the to request a call back.

Now lets see how we can write this requirement in Gherkin language.


feature1.feature
Copy
Feature: Requesting a call
  Scenario: Successful call request
    Given Request Call page is open
    And Contact number is entered
    And Requirement Summary is entered
    When User click on Request Call button
    Then Thank You message should be displayed

From the above feature file its very clear that what should be the functionality and each department will have clear idea what should be their responsibility and the task associated with this feature.

Based on the feature requirement the development team developed the feature. Lets assume following image is what they have created.

demo-website-2
Note:

Though there is no restriction to use multiple feature in a feature file, but the recommendation is to keep it to one.