Configuration
SpecBinder's behavior is controlled through the @Feature2JUnitOptions annotation.
Generation Modes
Concrete Mode (default)
The generated class is concrete with Assertions.fail() stubs for unimplemented steps. Override methods directly in your marker class:
@Feature2JUnit("login.feature")
public class LoginTest extends LoginFeature {
@Override
protected void whenTheUserLogsIn() {
// implement here
}
}
Abstract Mode
The generated class is abstract with abstract step methods. You must implement all steps:
@Feature2JUnit("login.feature")
@Feature2JUnitOptions(abstractSteps = true)
public class LoginTest extends LoginFeature {
// must implement all abstract step methods
}
Options Reference
| Option | Default | Description |
|---|---|---|
abstractSteps | false | Generate abstract step methods instead of concrete stubs |
emptyElementBehavior | FAIL | What to do with empty scenarios: FAIL, SKIP, or NONE |
dataTableParameterType | LIST_OF_MAPS | How data tables are passed: LIST_OF_MAPS, CUCUMBER_DATA_TABLE, or LIST_OF_OBJECT_PARAMS |
addSourceLineNumbers | true | Add source line number references in generated code |
includeStepKeyword | false | Include Given/When/Then keywords in generated method names |
cucumberAnnotationMatching | false | Match steps using Cucumber annotations |
Data Tables
SpecBinder supports type-safe data tables. Gherkin table rows are automatically mapped to generated Java record-like classes with strongly-typed fields:
Scenario: Multiple users
Given the following users:
| username | role |
| alice | admin |
| bob | viewer |
With LIST_OF_OBJECT_PARAMS, this generates a typed parameter class you can use directly in your step method.