1
我尝试使用高线测试和阿鲁巴宝石来剔除标准输出,但仍然停止我的黄瓜测试并要求用户输入。使用Cucumber测试此类应用程序是否有最佳做法?如何使用Highline测试Cucumber用户输入和输出?
我尝试使用高线测试和阿鲁巴宝石来剔除标准输出,但仍然停止我的黄瓜测试并要求用户输入。使用Cucumber测试此类应用程序是否有最佳做法?如何使用Highline测试Cucumber用户输入和输出?
Aruba给了我解决方案。 首先,我的错误是在不检查if __FILE__ == $0
的情况下创建应用程序根类的新实例。
最后它看起来像这样:
dashboard.feature:
Feature: Manage app with dashboard
As an app user
In order to control application
I want to have a dashboard
Scenario: View dashboard
When I run `../../lib/reporter.rb` interactively
Then I should see following choices
| 1 | Choice 1 |
| 2 | Choice 2 |
| 3 | Choice 3 |
steps.rb:
Then(/^I should see following choices$/) do |table|
menu = ''
table.rows_hash.each do |key, value|
menu << "#{key}. #{value}\n"
end
Timeout::timeout(exit_timeout) do
loop do
break if assert_partial_output_interactive(menu)
sleep 0.1
end
end
end