How to create cucumber BDD framework from scratch: Practical example
In this post, I’ll walk you through the complete workflow of my Cucumber BDD Framework project, which I developed to automate test scenarios for the website Automation Practice. You can explore the full project here: GitHub Repository .
1. Project Overview
This project is a hybrid automation framework based on Cucumber BDD using Java, Selenium WebDriver, and Maven. It supports Page Object Model (POM), and integrates with Jenkins CI/CD and GitHub for version control.
2. Folder Structure
📋 Folder Summary Table
Folder/File | Purpose |
---|---|
.vscode/ | IDE-specific settings and preferences. |
.mvn/ | Maven runtime configurations. |
src/main/java/com | Core reusable framework classes. |
factory/ | WebDriver setup and initialization. |
pages/ | Page Object Model (POM) design classes. |
utilities/ | Helper functions and utilities. |
src/test/java/ | Step definitions, hooks, and test runners. |
resources/com | Feature files and test configurations. |
target/ | Compiled outputs and reports (auto-generated). |
test-output/ | Execution reports and logs. |
pom.xml | Dependency and build management (Maven). |
README.md | Documentation for GitHub viewers. |
3. Key Dependencies (pom.xml)
<dependencies> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>7.11.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.12.1</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> </dependency> </dependencies>
Maven handles dependency management, test execution, and report generation through the maven-surefire-plugin
.
4. Cucumber BDD Workflow
- Business requirements are written as Gherkin feature files under
src/test/resources/com/features
. - Each scenario is linked to a corresponding Step Definition class in
stepDefinitions/
. - Step definitions interact with Page Objects to perform UI actions using Selenium.
- Hooks initialize the browser before tests and close it afterward.
- Reports are generated automatically post-execution.
5. CI/CD Integration (Jenkins + GitHub)
The project integrates with Jenkins using a webhook from GitHub. Whenever code is pushed to the repository:
- GitHub triggers a Jenkins build automatically.
- Maven downloads dependencies and runs Cucumber tests.
- Jenkins publishes HTML/JSON reports.
This setup ensures Continuous Integration and Continuous Testing for each code change.
6. Reports
Reports are generated using the Cucumber HTML Plugin and stored under the reports/
directory.
These reports summarize scenario execution status, steps passed/failed, and screenshots for failed cases.
7. Version Control (GitHub)
The entire project is version-controlled with Git. Typical commands used during workflow:
git init git add . git commit -m "Initial Cucumber BDD setup" git push origin main
8. Conclusion
This project demonstrates a professional-level Cucumber BDD automation framework integrating all key QA components — from test design to CI/CD. You can explore and clone the complete framework from my GitHub repository:
Comments
Post a Comment