How testdouble/java-cucumber-example works
Project type and purpose
• This is a sample Java-based test‐automation framework that demonstrates Behavior‐Driven Development (BDD) with Cucumber and UI testing with Selenium WebDriver.
• It contains:
• Feature files under src/test/resources (Cucumber .feature scenarios)
• Glue code under src/test/java (step definitions, support classes)
• A tiny “domain” class (skeleton/Belly.java) for demo purposes
• Build scripts (Maven’s pom.xml and Ant’s build.xml)
• WebDriver executables in bin/
File structure
• Top‐level build files: pom.xml (Maven), build.xml (Ant), .travis.yml for CI.
• src/main/java/skeleton: contains the Belly.java domain class used in the skeleton feature.
• src/test/java:
• skeleton, bank, selenium packages with RunCukesTest & Stepdefs (glue code)
• support/Browser.java (helper to instantiate WebDriver)
• src/test/resources: three feature‐file directories (skeleton, bank, selenium).
• bin/: Windows WebDriver executables (IEDriverServer.exe, chromedriver.exe).
Extract insights from the README
• Tests can be driven via JUnit (@RunWith(Cucumber.class)) or Cucumber CLI (Ant).
• CucumberOptions annotation or -Dcucumber.options can override feature paths, tags, plugins.
• Maven mvn test and Ant ant runcukes are the two entry points.
Main components
a. Build & CI layer
• Maven (Surefire + cucumber-junit)
• Ant (cucumber.api.cli.Main)
• Continuous integration (.travis.yml)
b. Test Orchestrator
• JUnit runner with @RunWith(Cucumber.class)
• Cucumber CLI main class
c. Feature Repository
• .feature files under src/test/resources
d. Glue code
• Step definitions (skeleton.Stepdefs, bank.Stepdefs, selenium.TodoSteps)
• Support classes (support.Browser, TodoUtil)
e. Domain under test
• skeleton.Belly.java (demo business logic)
f. External tooling
• Selenium WebDriver executables (chromedriver.exe, IEDriverServer.exe)
• Actual browser instances (Chrome, IE)
Relationships & data flow
• Build tool invokes Test Orchestrator
• Test Orchestrator reads .feature files → for each Scenario:
• Matches steps to methods in Step definitions
• Stepdefs call Support.Browser to spin up WebDriver → launches browser
• Stepdefs and Support classes may invoke domain code (e.g., Belly) or Selenium calls on pages
• WebDriver communicates with browser via driver executables
• Results and reports are emitted via Cucumber plugins (pretty, JUnit XML, rerun)
Architectural patterns & design principles
• BDD / Layered separation:
• Presentation: .feature files
• Glue: step definitions + support helpers
• Domain logic: Belly and any business helpers
• Infrastructure: WebDriver, browser executables
• Test‐first mindset: features drive development of glue and domain code.
• Plug‐in architecture: Cucumber’s plugin model for reporting, rerun, pretty.
Technologies, frameworks, and libraries
• Java 8+
• Cucumber-JVM (cucumber-java, cucumber-junit, cucumber-api)
• Selenium WebDriver
• JUnit 4
• Maven and Ant build systems
• Browser drivers (chromedriver, IEDriverServer)