0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

calabash-androidを動かす

Last updated at Posted at 2017-11-11

1.features/my_first.feature

my_first.feature
Feature: Login feature

Scenario: Success Login
	Then I wait for the "MainActivity" screen to appear
	Then I take a screenshot
	Then I enter text "kapibara" into field with id "input_user_id"
	Then I enter text "san" into field with id "input_password"
	Then I press the enter button
	Then I wait
	Then I take a screenshot
	Then I press "login_button"
	Then I wait for the "SubScreen" screen to appear
	Then I take a screenshot

Scenario: failure Login
	Then I wait for the "MainActivity" screen to appear
	Then I take a screenshot
	Then I enter text "failure" into field with id "input_user_id"
	Then I enter text "san" into field with id "input_password"
	Then I press the enter button
	Then I wait
	Then I take a screenshot
	Then I press "login_button"
    Then I wait
	Then I take a screenshot
	
Scenario: screen two transition
	Then I wait for the "MainActivity" screen to appear
	Then I take a screenshot
	Then I press "screen_two_button"
	Then I wait for the "ScreenTwo" screen to appear
	Then I take a screenshot

1.あらかじめ実機もしくはエミレーターをAndroid Studioから起動した状態にする。

2.calabashを起動する
calabash-android run /Users/non/nonAndroid201711/app/app-debug.apk

実行ログ⏬⏬⏬⏬⏬

Feature: Login feature

  Scenario: Success Login                                           # features/my_first.feature:3
    Then I wait for the "MainActivity" screen to appear             # calabash-android-0.9.0/lib/calabash-android/steps/progress_steps.rb:51
    Then I take a screenshot                                        # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9
    Then I enter text "kapibara" into field with id "input_user_id" # calabash-android-0.9.0/lib/calabash-android/steps/enter_text_steps.rb:13
    Then I enter text "san" into field with id "input_password"     # calabash-android-0.9.0/lib/calabash-android/steps/enter_text_steps.rb:13
    Then I press the enter button                                   # calabash-android-0.9.0/lib/calabash-android/steps/navigation_steps.rb:9
    Then I wait                                                     # calabash-android-0.9.0/lib/calabash-android/steps/progress_steps.rb:5
    Then I take a screenshot                                        # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9
    Then I press "login_button"                                     # calabash-android-0.9.0/lib/calabash-android/steps/press_button_steps.rb:17
    Then I wait for the "SubScreen" screen to appear                # calabash-android-0.9.0/lib/calabash-android/steps/progress_steps.rb:51
    Then I take a screenshot                                        # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9

  Scenario: failure Login                                          # features/my_first.feature:15
    Then I wait for the "MainActivity" screen to appear            # calabash-android-0.9.0/lib/calabash-android/steps/progress_steps.rb:51
    Then I take a screenshot                                       # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9
    Then I enter text "failure" into field with id "input_user_id" # calabash-android-0.9.0/lib/calabash-android/steps/enter_text_steps.rb:13
    Then I enter text "san" into field with id "input_password"    # calabash-android-0.9.0/lib/calabash-android/steps/enter_text_steps.rb:13
    Then I press the enter button                                  # calabash-android-0.9.0/lib/calabash-android/steps/navigation_steps.rb:9
    Then I wait                                                    # calabash-android-0.9.0/lib/calabash-android/steps/progress_steps.rb:5
    Then I take a screenshot                                       # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9
    Then I press "login_button"                                    # calabash-android-0.9.0/lib/calabash-android/steps/press_button_steps.rb:17
    Then I wait                                                    # calabash-android-0.9.0/lib/calabash-android/steps/progress_steps.rb:5
    Then I take a screenshot                                       # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9

  Scenario: screen two transition                       # features/my_first.feature:27
    Then I wait for the "MainActivity" screen to appear # calabash-android-0.9.0/lib/calabash-android/steps/progress_steps.rb:51
    Then I take a screenshot                            # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9
    Then I press "screen_two_button"                    # calabash-android-0.9.0/lib/calabash-android/steps/press_button_steps.rb:17
    Then I wait for the "ScreenTwo" screen to appear    # calabash-android-0.9.0/lib/calabash-android/steps/progress_steps.rb:51
    Then I take a screenshot                            # calabash-android-0.9.0/lib/calabash-android/steps/screenshot_steps.rb:9

3 scenarios (3 passed)
25 steps (25 passed)
0m47.066s

3-1.連続して実行する

my_first.feature
Feature: Login feature

Scenario Outline: Login
	Then I wait for the "MainActivity" screen to appear
	Then I take a screenshot
	Then I enter text "<userId>" into field with id "input_user_id"
	Then I enter text "<password>" into field with id "input_password"
	Then I press the enter button
	Then I wait
	Then I take a screenshot
	Then I press "login_button"
	Then I wait
	Then I take a screenshot
Examples:
|userId|password|
|test1|password1|
|test2|password2|
|test3|password3|
|test4|password4|
|test5|password5|
|test6|password6|
|test7|password7|

実行ログ⏬⏬⏬⏬⏬⏬

Feature: Login feature

  Scenario Outline: Login                                              # features/my_first.feature:3
    Then I wait for the "MainActivity" screen to appear                # features/my_first.feature:4
    Then I take a screenshot                                           # features/my_first.feature:5
    Then I enter text "<userId>" into field with id "input_user_id"    # features/my_first.feature:6
    Then I enter text "<password>" into field with id "input_password" # features/my_first.feature:7
    Then I press the enter button                                      # features/my_first.feature:8
    Then I wait                                                        # features/my_first.feature:9
    Then I take a screenshot                                           # features/my_first.feature:10
    Then I press "login_button"                                        # features/my_first.feature:11
    Then I wait                                                        # features/my_first.feature:12
    Then I take a screenshot                                           # features/my_first.feature:13

    Examples: 
      | userId | password  |
      | test1  | password1 |
      | test2  | password2 |
      | test3  | password3 |
      | test4  | password4 |
      | test5  | password5 |
      | test6  | password6 |
      | test7  | password7 |

7 scenarios (7 passed)
70 steps (70 passed)
1m50.470s
  1. Given:事前条件
  2. When:操作する
  3. Then:検証する
  4. And:「Given」「When」「Then」

http://www.atmarkit.co.jp/ait/articles/1504/09/news011_2.html
https://bitbar.com/creating-the-right-calabash-tests/
https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/canned_steps.md

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?