【发布时间】:2011-08-09 21:19:00
【问题描述】:
昨天我已经开始为我的 rails 应用程序实施黄瓜测试。我得到了正确的初始功能。但是当我编写功能时,我可以看到一些功能正在重复
例如:登录功能(场景),
我正在考虑如何通过在其他功能中调用这些功能来使这些步骤干燥。
我发现这篇文章也很有用
http://blog.mattwynne.net/2008/11/14/dry-up-your-cucumber-steps/
http://collectiveidea.com/blog/archives/2011/06/09/reusable-cucumber-steps/
但我认为,由于我是黄瓜的新手,我对如何实现重复功能有点困惑。
谁能给我指出正确的方向
我正在使用 Rails3
提前致谢
干杯 同龄人
编辑:
我有以下场景需要登录
Scenario: login
Given a user that is "test"
When I go to the homepage
Then I should see "Good Food"
When I fill in "user_session_login" with "test"
When I fill in "user_session_password" with "welcome"
When I press "user_session_submit"
Then I should see "Welcome test"
我还有另一个场景可以查看仪表板(用户登录后看到的初始页面)
Scenario: view_dashboard
<need to add the login feature here>
Then I should see <some link in dashboard>
我想在 view_dashboard 功能中添加登录功能,这样我就不想在仪表板中重复登录。
【问题讨论】:
-
很难理解你在问什么。你能发布一个实际的例子吗?
-
嗨@Andy,很抱歉造成混乱,我更新了帖子
标签: ruby-on-rails-3 cucumber bdd dry