Open In App

Cucumber Feature File

Last Updated : 11 Aug, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

A Feature File is a part of Cucumber, where you define the behavior of the application in a human-readable format using Gherkin syntax. This file gives us both the automation test script and live documentation.

Here are the steps to create a cucumber feature file:

Step 1. Set up Project

Before starting, ensure you have Java and Cucumber set up in your local Integrated Development Environment (IDE), and create a Maven project also.

Cucumber-Framework-Structure
Cucumber Framework Structure

Step 2. Install Cucumber Plugin

Go to Help - Eclipse Marketplace and search for "Cucumber" and install the plugin.

Eclipse-marketplace---cucumber-plugin
Cucumber plugin

Step 3. Create the Feature File

Right-click on the src/test/resources and create one file with .feature extension.

Login.feature

gherkin
Feature: User Login

  Scenario: Successful login with valid credentials
    Given the user is on the login page
    When the user enters valid username and password
    Then the user should be redirected to the homepage

Cucumber Feature File Structure:

  • Feature: Names the functionality being tested (e.g., "User Login").
  • Scenario: A single test case showing how the feature should behave.
  • Given: Sets up the starting point (e.g., "User is on the login page").
  • When: Describes the user’s action (e.g., "They enter username and password").
  • Then: States the expected result (e.g., "They see the homepage").
  • And/But: Adds extra conditions or actions (e.g., "And the username is valid").

Article Tags :

Explore