如何用坦率地写黄瓜测试

时间:2012-07-31 18:10:38

标签: ios unit-testing cucumber frank

我是使用cucumber / frank / ruby​​的新手,并尝试按照此处的步骤http://blog.thepete.net/blog/2012/06/24/writing-your-first-frank-test/ 我正在尝试创建一个步骤定义。在本教程中,他们为您提供了编写步骤定义的代码。这是样本步骤定义的代码:

Then /^I should be on the Home screen$/ do
  check_element_exists "view view:'UIImageView' marked:'Icon512x512.png'"
end
When /^I navigate to "(.*?)"$/ do |tab_name|
  touch "view:'UITabBarButton' marked:'#{tab_name}'"
end
Then /^I should be on the Events screen$/ do
  check_element_exists "view:'UIScrollView' view:'UIButton' marked:'archery'"
  check_element_exists "view:'UIScrollView' view:'UIButton' marked:'badminton'"
  check_element_exists "view:'UIScrollView' view:'UIButton' marked:'boxing'"
end

我尝试编写第一部分以应用于我的应用程序并将其写成:

Then /^I should be on the Map screen$/ do
  check_element_exists "view view:'UIButtonLabel' marked:'Photo View'"
end

它给了我错误  然后我应该在地图屏幕上#features / step_definitions / navigation_steps.rb:1       frankly_map视图:'UIButtonLabel'标记:'Photo View'accessibilityLabel失败,因为:选择器无效        * - [__ NSArrayM objectAtIndex:]:索引0超出空数组的边界(RuntimeError)       /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:53:in timeout' ./features/step_definitions/navigation_steps.rb:1:in / ^我应该在地图屏幕上$ /'       features / navigation.feature:5:在`那么我应该在地图屏幕上'

1 个答案:

答案 0 :(得分:0)

如果我理解正确,并且你正在访问默认按钮,你应该这样:

Then /^I should be on the Map screen$/ do
  check_element_exists "view view:'UIButton' marked:'Photo View'"
end

尝试发布您的共生体的屏幕截图,欢呼。