gpt4 book ai didi

ruby - 保持 cucumber 常见步骤的最佳实践

转载 作者:数据小太阳 更新时间:2023-10-29 07:17:53 33 4
gpt4 key购买 nike

我将 cucumber-watir-webdriver 用于自动化目的。我有以下目录结构:

|features
-|feature1
--|1.feature
--|step_definitions
---|1.rb
-feature2
--|2.feature
--|step_definitions
---|2.rb

等等。我需要知道什么是减少 1.rb2.rb 中冗余的最佳做法。feature1feature2 完全不同,所以我不能将两者合并到一个目录中。还有一些部分特征线相同,但执行步骤不同,所以如果它们放在一起会产生歧义。

我需要知道 1.rb2.rb 中是否有一些共同的部分,我应该把它放在哪里是保持共同步骤定义的最佳实践。

最佳答案

将您的功能分离到单独的目录中很好,但最好将您的 *_step.rb 文件放在 features 下的一个 step_definitions 目录中 目录。您可以将这两个功能共有的步骤放入 common_steps.rb 文件(更好的做法是像 login_steps.rbtest_data_creation_steps.rb common_steps.rb)。

要将其转换为与您的问题相同样式的目录结构图,我建议如下:

|features
-|feature1
--|1.feature
-feature2
--|2.feature
-|step_definitions
--|1.rb
--|2.rb
--|common_steps.rb <-- put your common steps in here

关于ruby - 保持 cucumber 常见步骤的最佳实践,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12910763/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com