Cucumberを使って iPhone のテスト
Frankというやつがある。
- http://blog.thepete.net/blog/2012/06/24/writing-your-first-frank-test/
- http://testingwithfrank.com/
- https://github.com/moredip/Frank
一番上のプログが一番役立った。
githubにあった iosアプリを例に 素振りしてみた。
https://github.com/haru01/cheddar-ios
動かし方は Readme を参考に。(cheddarのユーザ登録、https://cheddarapp.com/developer/appsを参考に、CDIDefines.mの修正が必要。 )
記述ポイントは、次のファイル
https://github.com/haru01/cheddar-ios/blob/master/Frank/features/register_modify_delete_todo.feature
# encoding:utf-8 Feature: TODO List Scenario: タスクを追加編集削除できる Given I launch the app Then タスクリストを登録できる Then タスクを登録できる Then タスク名を編集できる Then タスクを削除できる Then タスクリストを削除できる
https://github.com/haru01/cheddar-ios/blob/master/Frank/features/step_definitions/tasks_steps.rb
# encoding:utf-8 World(TaskStepHelper) When /^I type keybord "(.*?)" and enter$/ do |key| type_into_keyboard key end Then /^タスクを登録できる$/ do step %Q|I touch "#{todo_list_name}"| step %Q|I wait to see "#{what_do_you_have_to_do}"| step %Q|I touch "#{what_do_you_have_to_do}"| step %Q|I wait for 1 second| step %Q|I type keybord "#{first_task_name}" and enter| end Then /^タスク名を編集できる$/ do step %Q|I touch "#{lists_button}"| step %Q|I touch "#{todo_list_name}"| step %Q|I touch "#{edit_button}"| step %Q|I touch "#{first_task_name}"| step %Q|I wait for 1 second| step %Q|I type keybord "EF" and enter| end Then /^タスクを削除できる$/ do step %Q|I wait for 1 second| step %Q|I touch "#{lists_button}"| step %Q|I touch "#{todo_list_name}"| step %Q|I touch "#{edit_button}"| step %Q|I touch "Delete"| step %Q|I touch "#{achirve_button}"| step %Q|I touch "#{lists_button}"| end Then /^タスクリストを登録できる$/ do step %Q|I touch "#{lists_button}"| step %Q|I touch "#{plus_button}"| step %Q|I wait for 1 second| step %Q|I type keybord "#{todo_list_name}" and enter| end Then /^タスクリストを削除できる$/ do step %Q|I touch "#{edit_button}"| step %Q|I touch "Delete"| step %Q|I touch "#{achirve_button}"| end
既にあるステップは、下記が 参考になる。
- http://testingwithfrank.com/supplied_steps.html
- https://github.com/moredip/Frank/blob/master/gem/lib/frank-cucumber/core_frank_steps.rb
iOS独特のセレクターでうまく、画面要素を指定するキーを見つけるのがちょっとわかりにくい。
一応、要素をさがすためのinspectorも付いてくるのでそこから探すのだが。。。。
$frank inspect