java - Cucumber Runner Class 未运行 Step Definitons
问题描述
我正在用 Cucumber 和 Java 编写自动化测试。
我可以通过右键单击我的 Feature 文件来运行步骤定义,并将其作为 Cucumber Feature 运行,并且所有步骤都成功通过。
但是,我需要使用 Runner 类来运行它们。
我的功能文件在这个文件夹中:
src/test/java/features
我的步骤定义在这个文件夹中:
src\test\java\com\abc\commercial\def\automation
我的 Runner Class 也存储在
src\test\java\com\abc\commercial\def\automation
这是 Runner 类的代码:
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"progress",
"html:build/report/html",
"junit:build/report/junit/cucumber-report.xml",
"json:build/report/json/cucumber-report.json"
},
glue = {"src\\test\\java\\com\\abc\\commercial\\def\\automation"},
features = {"src/test/java/features"}
)
public class QARunner {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
当我将 Runner 类作为 JUnit 测试运行时,我在控制台中收到以下响应:
UUUUUUUUU
Undefined scenarios:
src/test/java/features/US46052
src/test/java/features/postFeatures.feature:43 # As the
2 Scenarios (2 undefined)
9 Steps (9 undefined)
0m0.303s
You can implement missing steps with the snippets below:
@Given("the Application...")
public void the_Application...() {
所以步骤定义没有被拾取。
它与我的测试运行器所在的位置有关吗?我认为它不会在自动化文件夹中获取步骤定义
谢谢你的帮助
解决方案
试试这个:不需要主要方法。glue
选项应该是包样式。
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"progress",
"html:build/report/html",
"junit:build/report/junit/cucumber-report.xml",
"json:build/report/json/cucumber-report.json"
},
glue = {"com.abc.commercial.def.automation"},
features = {"src/test/java/features"}
)
public class QARunner {
}
推荐阅读
- java - 如何正确返回基于用户 ID 显示数据的数组列表?
- python - TypeError:“str”对象不能解释为整数。创建一个新的 .csv 文件。键错误:'Id'
- sql - Oracle nvl 功能未按预期工作
- javascript - 如何等待函数执行直到订阅完成?
- java - 使用 Apache POI 获取行数
- python - WTForms 复选框字段未填充
- windows - mongocxx 驱动程序的 libbson 版本问题 [Windows 操作系统]
- c# - 交互式/链接图表
- akka-stream - 将 `func(in: Source[A]) : Source[B]` 转换为 `Flow[A, B]`
- python - 使用 numpy 创建对角矩阵返回零方阵