Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link feature and step definition in cucumber

I'm new to Cucumber java and had this problem in initial stages: I'm not using MAVEN project for some reason. I just created a simple java project in eclipse.

I have my features under "src/dummy/pkg/features", and my implementation "StepDef.java" is under "src/dummy/pkg/features/implementation"

I have written step definitions for Given, When, and Then, but when I run my features file, it is unable to recognize the implementation. How do I link the features with step definitions?

like image 557
user85 Avatar asked Dec 26 '22 03:12

user85


1 Answers

create a class YourClass and it would look something like the below and run it as JUnit test.

@RunWith(Cucumber.class)

@CucumberOptions(  monochrome = true,
                     features = "src/dummy/pkg/features/",
                       format = { "pretty","html: cucumber-html-reports",
                                  "json: cucumber-html-reports/cucumber.json" },
                         glue = "your_step_definition_location_package" )

public class YourClass {
  //Run this from Maven or as JUnit
}
like image 120
Bala Avatar answered Jan 12 '23 18:01

Bala