Reputation: 67
I'm having a problem mapping the glue code from my Feature file to step definition code.
@RunWith(Cucumber.class)
@CucumberOptions(`enter code here`
features = "Features/store.feature"
,glue={"com.test.stepdefinitions/Store.java"}
,monochrome = true
,format={"junit:reports/junit/reports.xml","pretty", "html:reports/html","json:reports/json/Store_reports.json"}
)
public class StoreRunner {
}
When I run this, it will throw this console message:
Feature: Store
Scenario: Delete item from checkout page # Features/store.feature:3
Given the user is in the checkout page # null # null
Upvotes: 0
Views: 1669
Reputation: 21
All you have to do is mentions the Step-definition class name in @CucumberOptions.
Here is the format
@CucumberOptions
{
feature={"path of feature file with extension"},
glue={"Step-definition package Name.class-Name"}
}
Upvotes: 0
Reputation: 67
Aprreciate your help guys. I'm able to solve this issue using the latest cucumber version 3.1.0 from io.cucumber and latest selenium jar file from seleniumhq.
Here's my code:
@RunWith(Cucumber.class)
@CucumberOptions(
features = "Features/store.feature"
,glue={"com.bitpoints.stepdefinitions"}
,monochrome = true
,format={"junit:reports/junit/reports.xml","pretty", "html:reports/html","json:reports/json/Login_reports.json"}
)
public class StoreRunner {
}
As you can see I've included "Features/store.feature" in features and it was able to pick the store feature file to be run.
Hope this helps
Upvotes: 1
Reputation: 589
Here is an example of code:
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/java/features/", glue = {"steps"}, plugin = {"pretty", "html:target/cucumber", "json:target/cucumber.json"})
public class RunFeaturesTest {}
project architecture :
Upvotes: 0
Reputation: 193168
It is not clear from your question if you are using Maven or not but looking at the reports I presume are using Maven.
To map the glue code from the Feature file to Step Definition you need to format the Test Runner class as follows :
plugin
argument.Your Test Runner class file will look like :
@RunWith(Cucumber.class)
@CucumberOptions(
features="Features",
glue={"stepdefinitions"},
monochrome = true,
plugin={"junit:reports/junit/reports.xml"
"pretty:target/cucumber-pretty.text",
"html:target/cucumber-html-report",
"json:target/cucumber.json",
"usage:target/cucumber-usage.json",
)
public class ReportTestRunner
{
}
Upvotes: 0