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.
- Supports
Given / When / Thensyntax from.featurefiles - 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
mini-cucumber/
├── pom.xml
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ ├── annotations/ # Custom annotations
│ │ │ ├── steps/ # Step definition classes
│ │ │ └── core/ # MiniCucumber engine
│ └── resources/
│ └── features/ # .feature test files
│ └── login.feature
- Run the engine Run the MiniCucumber.java class, or from command line:
mvn compile exec:java -Dexec.mainClass="core.MiniCucumber"- 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- 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() { ... }• Add support for {int}, {float}, etc. • Scenario Outline + Examples table • Assertions and test result tracking • HTML / JSON reporting • Hook support (@Before, @After)
• Java 8+ • Maven • IntelliJ IDEA • Reflection + Custom Annotation + File Parsing
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.
MIT License – Feel free to use, fork, and star ⭐