Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🥒 MiniCucumber – A Lightweight Java BDD Engine

MiniCucumber is a minimal, self-built BDD testing engine written purely in Java.
It mimics the core behavior of Cucumber to help developers understand how BDD tools work under the hood — including annotation parsing, regex matching, parameter injection, and .feature file interpretation.


🚀 Features

  • Supports Given / When / Then syntax from .feature files
  • Custom annotations: @Given, @When, @Then
  • {string} parameter matching and injection
  • Regex-based step matching
  • Automatically invokes mapped Java methods
  • No Cucumber dependency required — ideal for learning and experimenting

📦 Project Structure

mini-cucumber/
├── pom.xml
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   ├── annotations/      # Custom annotations
│   │   │   ├── steps/            # Step definition classes
│   │   │   └── core/             # MiniCucumber engine
│   └── resources/
│       └── features/             # .feature test files
│           └── login.feature
  1. Run the engine Run the MiniCucumber.java class, or from command line:
mvn compile exec:java -Dexec.mainClass="core.MiniCucumber"
  1. Example .feature file
Feature: Login

Scenario: Successful login
Given the user is on the login page
When the user logs in with "cj" and "123456"
Then the user sees the homepage
  1. Corresponding Java step definitions
@Given("the user is on the login page")
public void goToLoginPage() { ... }

@When("the user logs in with {string} and {string}")
public void login(String username, String password) { ... }

@Then("the user sees the homepage")
public void seeHomepage() { ... }

✨ Possible Enhancements

• Add support for {int}, {float}, etc. • Scenario Outline + Examples table • Assertions and test result tracking • HTML / JSON reporting • Hook support (@Before, @After)

🧠 Tech Stack

• Java 8+ • Maven • IntelliJ IDEA • Reflection + Custom Annotation + File Parsing

🧠 Design Patterns Used

This project demonstrates the use of several fundamental software design patterns behind behavior-driven development (BDD) tools like Cucumber:

Pattern Where It’s Used
Annotation Processing Custom annotations like @Given, @When, and @Then are used to mark methods as step definitions.
Reflection Dynamically scans and invokes methods based on runtime annotations and matched patterns.
Factory Pattern Conceptually used to instantiate step classes dynamically (e.g., newInstance() for MySteps).
Strategy Pattern The matching logic acts like a strategy selector for which method to execute based on regex.
Command Pattern Each step is treated like a command that encapsulates behavior and is executed when matched.
Interpreter Pattern Parsing .feature files and interpreting steps line-by-line follows this classic DSL parsing pattern.

This structure reflects the fundamental architecture of tools like Cucumber, stripped down for learning and experimentation.

📄 License

MIT License – Feel free to use, fork, and star ⭐

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages