In order to automate any application in Cucumber tool, we need to create 3 files
Feature file
Step Definition file
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.
Kommentare