Java – How to set the path to the Cucumber features using cucumber-junit


I try to build my first executable specifications with Java and Maven. I created a simple project with this structure:


In the junit test I have this:

import org.junit.runner.RunWith;
import cucumber.junit.Cucumber;

public class HomepageTest {

Now says that I should add the following line:


I tried to modify that to


but the annotation @Cucumber.Options isn't available at all. My pom.xml has this dependencies:


Am I missing something?

Update I was missing something: The cucumber feature file has to be in a subdirectory src/test/resources/mypackage/. Otherwise it won't be picked up by the junit test.

I can run my feature tests when I put them in the same directory src/main/test/, so it's not a blocker for me. But I'd like to understand the whole setup.

Best Solution

Take a look at my question here:

You can specify a location on the classpath by setting the feature attribute in the options annotation like



in new versions code is