我可以使用不在当前文件夹层次结构下的另一个文件夹中的 Stepdefinitions 吗?

Can I use Stepdefinitions from a another folder which is not under my current folder hierarchy?

我想将项目中现有的 step_definitions 用于另一组黄瓜 ruby 测试。

Eg: 
|
|- common
|   |- step_difinitions
|   |- feature_file.feature
|
|- Some_other_folder
|   |- someother_feature.feature
|   |- ***Want to reuse the step_difinitions from common folder***

这可能吗?如果没有,是否有任何解决方法?

我将 step_defs 从常用功能文件文件夹移到 features 文件夹并使用了

-r features/step_definitions 而 运行 cucumber CLI 命令。

我对黄瓜命令进行了包装。因此,请确保在黄瓜命令中使用 -r path

感谢@supputuri 的帮助!

确保步骤定义在 features 文件夹下(sub-folder 中的任何位置也可以)。然后你必须使用下面的命令来 pick-up 和 step-defs 作为你的功能执行的一部分。

-r features_folder_path_goes_here

如果您使用的是 ruby​​mine,那么您可以转到 Run > Edit Configuration 并输入 Runner Options : --color -r feature_folder_path_goes_here 或者您可以简单地指定 --color -r features.

仅供参考 - --color 与此问题无关,它将确保输出以彩色显示。