Convention Discovery
@Gherkin2JUnit with no path argument — the processor finds feature files by convention, looking in the same package as the marker class.
Source: examples/common-use-cases/example-6 on GitHub.
What this demonstrates
- A bare
@Gherkin2JUnit(no value) triggers convention-based discovery - The processor scans for
.feature/.specbfiles in the same package as the annotated class - Feature files can live in
src/test/javanext to their marker class — easy to navigate in the IDE - Maven
testResourcesconfiguration is required to copy the feature files to the classpath
Directory layout
src/test/java/
└── com/example/shop/
├── ShoppingCart.java ← marker class (@Gherkin2JUnit)
└── ShoppingCart.feature ← co-located feature file
Both files share the same package — one click to jump between them in your IDE.
The marker class
ShoppingCart.java
package com.example.shop;
import dev.specbinder.annotations.Gherkin2JUnit;
@Gherkin2JUnit
public abstract class ShoppingCart {
}
Required Maven configuration
To make Maven copy .feature files from src/test/java to the test classpath:
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<includes>
<include>**/*.feature</include>
<include>**/*.specb</include>
</includes>
</testResource>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
</build>
Without this, Maven won't include the co-located feature files on the classpath and the processor won't find them.
Run it
cd examples/common-use-cases/example-6
mvn test