我在将胶水代码从我的Feature文件映射到步骤定义代码时出现问题。
@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 {
}
当我运行它时,它将抛出此控制台消息:
功能:存储
场景:从结帐页面删除项目#Features / store.feature:3
鉴于用户在结帐页面#null #null
答案 0 :(得分:0)
从您的问题中不清楚您是否使用Maven,但查看报告我认为正在使用 Maven 。
要将胶水代码从功能文件映射到步骤定义,您需要格式化 Test Runner 类,如下所示:
plugin
参数中移动格式属性。您的 Test Runner 类文件如下所示:
@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
{
}
答案 1 :(得分:0)
以下是代码示例:
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/java/features/", glue = {"steps"}, plugin = {"pretty", "html:target/cucumber", "json:target/cucumber.json"})
public class RunFeaturesTest {}
项目架构:
答案 2 :(得分:0)
感谢你的帮助。我可以使用io.cucumber的最新黄瓜版本3.1.0和seleniumhq的最新selenium jar文件来解决这个问题。
这是我的代码:
@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 {
}
正如您所看到的,我在功能中包含了“功能/ store.feature”,并且能够选择要运行的商店功能文件。
希望这有帮助
答案 3 :(得分:0)
您所要做的就是在@CucumberOptions中提及步骤定义类名称。
这是格式
@CucumberOptions
{
feature={"path of feature file with extension"},
glue={"Step-definition package Name.class-Name"}
}