小编Uda*_*ami的帖子

保持黄瓜共同步骤的最佳做法

我正在使用cucumber-watir-webdriver进行自动化.我有以下目录结构:

|features
 -|feature1
 --|1.feature
 --|step_definitions
 ---|1.rb
 -feature2
 --|2.feature
 --|step_definitions
 ---|2.rb
Run Code Online (Sandbox Code Playgroud)

等等.我需要知道什么是减少冗余的最佳实践1.rb2.rb. feature1并且feature2完全不同,所以我不能将它们组合在一个目录中.还有一些部分,其中特征线相同但步骤中的执行是不同的,因此如果它们在一起会产生歧义.

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

ruby automated-tests watir cucumber watir-webdriver

5
推荐指数
1
解决办法
1481
查看次数

如何在黄瓜步骤定义之外使用rspec-expectations

我正在使用watir-cucumber进行测试自动化。我单独编写了以下方法.rb,该方法不在步骤定义中。

 def has_logged_in?
   $browser.text.should include("t788")
 end
Run Code Online (Sandbox Code Playgroud)

当我从步骤定义中调用此方法时,就会出现此错误,

 wrong argument type String (expected Module) (TypeError)
Run Code Online (Sandbox Code Playgroud)

相同的代码在步骤定义中效果很好。我四处搜索,发现该include方法用于包含模块,但这是ruby-includemethod并should include在下面rspec\expectations。因此,如何在should include上述步骤定义之外调用方法。我在Linux上使用watir-cucumber

ruby rspec watir cucumber watir-webdriver

1
推荐指数
1
解决办法
1615
查看次数

标签 统计

cucumber ×2

ruby ×2

watir ×2

watir-webdriver ×2

automated-tests ×1

rspec ×1