top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-
Writer's pictureUsha Kurra

How to glue a Feature file to specific Step Definition file in cucumber

In order to automate any application in Cucumber tool, we need to create 3 files

  1. Feature file

  2. Step Definition file

  3. Runner file


When i was working on my first cucumber project, i have a faced an issue where my feature file is getting glued to incorrect Step Definition file. Here is the issue.




Initially I thought we need to have only one feature file with distinct gherkins. We can't re-use the gherkins in other feature files. But you can re-use gherkins . You have to create a runner file and glue the specific step to specific feature file. We have to create runner file under src/tst/java/StepDefinition. Here is the syntax.


package StepDefinition;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;

import io.cucumber.junit.CucumberOptions;


@RunWith(Cucumber. Class)

@CucumberOptions(features="src/test/resources/features", glue={"StepDefinition"},

plugin = {"pretty","html:target/HtmlReports1/report.html",

"json:target/JSONReports/report.json",

"junit:target/JUnitReports/report.xml"}

)

public class Runner {

}


This way we can have feature file connected to appropriate step definition file.


1,477 views0 comments

Kommentare

Mit 0 von 5 Sternen bewertet.
Noch keine Ratings

Rating hinzufügen
bottom of page