【发布时间】:2022-01-19 12:24:39
【问题描述】:
我有以下带有 Junit 和 Cucumber 的 Maven 项目结构:
| root project
| Module 1
| src
| main
| test
| java
| tests // where all step definitions from Module 1 are stored
| resources
| features // feature files from Module 1
| Module 2
| src
| main
| test
| java
| tests // where all step definitions from Module 2 are stored
| resources
| features // feature files from Module 2
我想在模块 2 中重复使用模块 1 中的步骤。是否可以将模块 1 中的步骤定义导入到模块 2 中以在那里重复使用它们?
【问题讨论】:
-
是的,这是可能的。取决于您是否已经自己进行了一些试验?
-
是的,我尝试将 Module1 添加为 Module2 的依赖项,并在黄瓜运行器类中设置“胶水”,但它仍然抛出“UndefinedStepException”异常。另外,我在其他地方发现,将步骤定义导出到单独的 jar 文件中可能会有所帮助,但不确定这是否是正确的方法。