Skip to main content

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

OptionDefaultDescription
abstractStepsfalseGenerate abstract step methods instead of concrete stubs
emptyElementBehaviorFAILWhat to do with empty scenarios: FAIL, SKIP, or NONE
dataTableParameterTypeLIST_OF_MAPSHow data tables are passed: LIST_OF_MAPS, CUCUMBER_DATA_TABLE, or LIST_OF_OBJECT_PARAMS
addSourceLineNumberstrueAdd source line number references in generated code
includeStepKeywordfalseInclude Given/When/Then keywords in generated method names
cucumberAnnotationMatchingfalseMatch 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.