Content ITV PRO
This is Itvedant Content department
Writing Step Code
Learning Outcome
4
Use parameters and expressions in steps
3
Write basic step definition methods and Organize and reuse step code
2
Map Gherkin steps (Given/When/Then) to code
1
Understand purpose of step definitions in Cucumber
5
Integrate with frameworks like JUnit / TestNG
Recall
Basic understanding of Cucumber and BDD concepts
Knowledge of Gherkin syntax (Given, When, Then)
Fundamentals of a programming language (e.g., Java, Python, JavaScript)
Basics of OOP (classes, methods, variables)
Understanding of unit testing frameworks like JUnit or TestNG
Familiarity with IDEs (e.g., Eclipse IDE, IntelliJ IDEA)
Basic knowledge of automation testing concepts
Using Cucumber is like using Google Maps:
Gherkin steps (Given/When/Then) = the route you see (what should happen)
Step definitions = the actual driving instructions (how it happens)
We use Feature Files in BDD to clearly describe and organize how a software system should behave.
It used to ,
Why do we use Feature File?
To describe system functionality in simple, readable language
To organize related test scenarios under one feature
To convert requirements into structured test cases
To improve communication between developers, testers, and business teams
To ensure a shared understanding of expected behavior
To support automation testing using tools like Cucumber
To make test cases easy to maintain and update
What is Feature File?
A Feature File is a text file used in Behavior-Driven Development (BDD) to describe the functionality of a software system in a simple, structured, and human-readable format using Gherkin syntax.
It describes a specific feature of an application (e.g., login, search, payment)
Written in plain English using Gherkin keywords
Contains scenarios that define system behavior
Helps both technical and non-technical teams understand requirements
Helps both technical and non-technical teams understand requirements
Can be used for automation testing with tools like Cucumber
Feature File Structure
A Feature File follows a fixed structure using Gherkin syntax:
Feature File Structure
Example : Feature: Login functionality
Scenario: Successful login
Given user is on login page
When user enters valid credentials
Then user is redirected to dashboard
Group related scenarios under one feature
Feature Files help in organizing testing logically:
One Feature File = One functionality
Multiple scenarios = different behaviors of that feature
Example
Feature: Login Functionality
Scenario 1: Valid login
Scenario 2: Invalid login
Scenario 3: Forgot password
This helps in better organization and easier maintenance.
Summary
4
3
Groups related test scenarios under one feature
2
Structure: Feature → Scenario → Given–When–Then
1
Describes software behavior in BDD and Written using Gherkin syntax
5
Makes requirements clear and readable for all teams
Used for automation testing with Cucumber
Quiz
What is a Feature File used for?
A. Writing programming code
B. Describing software behavior in BDD
C. Designing databases
D. Creating UI designs
Quiz-Answer
What is a Feature File used for?
A. Writing programming code
B. Describing software behavior in BDD
C. Designing databases
D. Creating UI designs
By Content ITV