Skip to main content
SpecBinder Logo

SpecBinder

Compile-time Gherkin to JUnit transformer

1

Write spec

specs/cart.feature
Feature: Shopping cart
Scenario: Update quantity
Given my cart has "honey"
And price is "15.00"
When I set qty to "2"
Then subtotal is "30.00"
2

Add marker class

@Gherkin2JUnit
class CartFeature {
}
3

Compile

</>SpecBinderAnnotationProcessor
4

Generated test

abstract class CartScenarios
extends CartFeature {
<...>
@Test
void scenario_1() {
myCartHas$p1("honey");
iSetQtyTo$p1("2");
priceIs$p1("15.00");
subtotalIs$p1("30.00");
}
}
5

Implement steps

class CartTest extends
CartScenarios {
void myCartHas$p1(String p1)
{ // TODO: implement }
void priceIs$p1(Double p1)
{ // TODO: implement }
void iSetQtyTo$p1(Integer p1)
{ // TODO: implement }
void subtotalIs$p1(Double p1)
{ // TODO: implement }
}
6

Run & debug

in IDE or CI
like any JUnit test
Why it helps

Compile-time safety

Gherkin specs are translated to Java during the build, so javac checks the binding. Missing steps, wrong parameter types, invalid enum values, broken data table columns — caught before any test runs.

Learn more →

Plain JUnit 5

No Cucumber runner, no step discovery, no parallel toolchain. Generated scenarios are ordinary @Test methods that your IDE, build, and CI run, debug, and report on like any other JUnit test.

Learn more →

Feature-scoped steps

No global step registry, no runtime lookup, no ambiguous matches. Each feature gets its own generated test class, so steps belong to the feature that uses them — shared deliberately through Java inheritance when that actually helps.

Learn more →

Simple state management

No ScenarioContext, no string-keyed maps, no DI container for moving values between steps. State lives in ordinary fields on the test class, reset for each scenario by JUnit's default lifecycle.

Learn more →

Type-safe data tables

No string-keyed row maps, no manual cell parsing, no late surprises from renamed columns. Each table row becomes a typed parameter object — column drift, type mismatches, and invalid enum values surface at compile time.

Learn more →

TDD-friendly

Red-green-refactor works at every level of detail. A rule with no scenarios fails. A scenario with no steps fails. A scenario with steps fails until they're implemented. The TDD loop pulls you top-down to the next missing piece.

Learn more →