kraken-mobile 1.0.2 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +251 -75
  3. data/bin/kraken-mobile +64 -67
  4. data/bin/kraken_mobile_calabash_android.rb +39 -0
  5. data/bin/kraken_mobile_helpers.rb +107 -0
  6. data/bin/kraken_mobile_setup.rb +138 -0
  7. data/calabash-android-features-skeleton/step_definitions/mobile_steps.rb +1 -0
  8. data/calabash-android-features-skeleton/support/app_installation_hooks.rb +2 -0
  9. data/calabash-android-features-skeleton/support/app_life_cycle_hooks.rb +3 -4
  10. data/calabash-android-features-skeleton/support/env.rb +1 -1
  11. data/calabash-android-features-skeleton/web/step_definitions/web_steps.rb +3 -0
  12. data/calabash-android-features-skeleton/web/support/app_life_cycle_hooks.rb +15 -0
  13. data/lib/kraken-mobile/device_process.rb +130 -0
  14. data/lib/kraken-mobile/helpers/devices_helper/adb_helper.rb +100 -105
  15. data/lib/kraken-mobile/helpers/kraken_faker.rb +108 -0
  16. data/lib/kraken-mobile/helpers/reporter.rb +3 -0
  17. data/lib/kraken-mobile/hooks/mobile_kraken_hooks.rb +15 -0
  18. data/lib/kraken-mobile/hooks/mobile_operations.rb +36 -0
  19. data/lib/kraken-mobile/hooks/web_operations.rb +33 -0
  20. data/lib/kraken-mobile/mobile/adb.rb +66 -0
  21. data/lib/kraken-mobile/mobile/android_commands.rb +43 -0
  22. data/lib/kraken-mobile/mobile/mobile_process.rb +101 -0
  23. data/lib/kraken-mobile/models/android_device.rb +121 -0
  24. data/lib/kraken-mobile/models/device.rb +113 -31
  25. data/lib/kraken-mobile/models/feature_file.rb +135 -0
  26. data/lib/kraken-mobile/models/feature_scenario.rb +24 -0
  27. data/lib/kraken-mobile/models/web_device.rb +89 -0
  28. data/lib/kraken-mobile/monkeys/mobile/android_monkey.rb +30 -0
  29. data/lib/kraken-mobile/monkeys/mobile/kraken_android_monkey.rb +54 -0
  30. data/lib/kraken-mobile/monkeys/web/web_monkey.rb +63 -0
  31. data/lib/kraken-mobile/runners/calabash/android/monkey_helper.rb +2 -2
  32. data/lib/kraken-mobile/runners/calabash/android/steps/communication_steps.rb +18 -2
  33. data/lib/kraken-mobile/runners/calabash/monkey/monkey_runner.rb +2 -2
  34. data/lib/kraken-mobile/steps/general_steps.rb +83 -0
  35. data/lib/kraken-mobile/steps/mobile/kraken_steps.rb +72 -0
  36. data/lib/kraken-mobile/steps/web/kraken_steps.rb +109 -0
  37. data/lib/kraken-mobile/test_scenario.rb +227 -0
  38. data/lib/kraken-mobile/utils/feature_reader.rb +17 -0
  39. data/lib/kraken-mobile/utils/k.rb +68 -0
  40. data/lib/kraken-mobile/utils/mobile_cucumber.rb +2 -0
  41. data/lib/kraken-mobile/utils/reporter.rb +500 -0
  42. data/lib/kraken-mobile/version.rb +2 -2
  43. data/lib/kraken-mobile/web/web_process.rb +41 -0
  44. data/lib/kraken_mobile.rb +81 -0
  45. data/reporter/assets/images/krakenThumbnail.jpg +0 -0
  46. data/reporter/feature_report.html.erb +5 -1
  47. data/reporter/index.html.erb +13 -7
  48. metadata +94 -13
  49. data/bin/kraken-mobile-calabash-android.rb +0 -85
  50. data/bin/kraken-mobile-generate.rb +0 -19
  51. data/bin/kraken-mobile-helpers.rb +0 -48
  52. data/bin/kraken-mobile-setup.rb +0 -50
  53. data/calabash-android-features-skeleton/step_definitions/kraken_steps.rb +0 -1
  54. data/lib/kraken-mobile.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bc931cd463cf275dd15848f6f5751461275b72c8
4
- data.tar.gz: 83c25030dcf11cd2bd403b2f31b76948c73fea07
2
+ SHA256:
3
+ metadata.gz: e37d1eb17311d98492fa285efa6be0ad6b99d674b2510497983d91a2ac468068
4
+ data.tar.gz: af154d6ce69ee8cc48a51155152e4d5e47304d6c97e996a78c68d5c8c62f270f
5
5
  SHA512:
6
- metadata.gz: 99bf9ad2a91215798445e26e16fe0377bd8ba6dc0cea908166592c23819362444e082120562743663e299004df7918667cec8454ff375778b79f5e354b7fc5b5
7
- data.tar.gz: e4d9af2856eef33da3d740a1cbf642492383490947a00bae2c765f13553efa863c8739fdd95bb571e38b279c456bf67cfd59238c0c69da27e7c7a872c848fb39
6
+ metadata.gz: 67d048888f05bf62f93b1a59078a45df13ab1beb239eef464130085fbe5e90ad5066d96019f485e9c3ce29e1f86b2eaf549b9ecb6ea80fdd9c432da0e31674b7
7
+ data.tar.gz: a50c7e482c919e3654c73053d459fbb10b173c4b0886995bd09851492d008ae25fff2ce195d22d3b95a4b656bc01ab8d43ab942f90a2b01c48ccb96f4b4d8f98
data/README.md CHANGED
@@ -1,86 +1,100 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/ravelinx22/KrakenMobile/master/reporter/assets/images/kraken.png" alt="kraken logo" width="140" height="193">
3
- </p>
2
+ <img src="./reporter/assets/images/kraken.png" alt="kraken logo" width="140" height="193">
3
+ <h1 align="center">Kraken</h1>
4
4
 
5
- <h3 align="center">Kraken Mobile</h3>
5
+ Kraken is an open source automated android and web E2E testing tool that supports and validates scenarios that involve the inter-communication between two or more users. It works in a Black Box manner meaning that it is not required to have access to the source code of the application but instead it can be run with the APK (Android package file format) and web page URL. Kraken uses signaling for coordinating the communication between the devices using a file based protocol.
6
6
 
7
- <p align="center">Kraken is an open source automated android E2E testing tool that supports and validates scenarios that involve the inter-communication between two or more users. It works in a Black Box manner meaning that it’s not required to have access to the source code of the application but instead it can be run with the APK (Android package file format). Kraken uses signaling for coordinating the communication between the devices using a file based protocol.</p>
7
+ **Kraken is partially supported by a Google Latin America Research Award (LARA) 2018**
8
8
 
9
- ## Table of contents
9
+ # Video
10
+ [![krakenThumbnail](./reporter/assets/images/krakenThumbnail.jpg)](https://www.youtube.com/watch?v=hv5gFIpW3gM&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=1)
10
11
 
11
- - [Technologies](#technologies)
12
- - [Installation](#installation)
13
- - [Signaling](#signaling)
14
- - [Writing your first test](#writing-your-first-test)
15
- - [Kraken steps](#kraken-steps)
16
- - [Running your tests](#running-your-tests)
17
- - [Kraken Settings](#kraken-settings)
18
- - [Properties file](#properties-file)
12
+ # Publications
19
13
 
20
- ## Technologies
14
+ - *“Kraken-Mobile: Cross-Device Interaction-based Testing of Android Apps”*, [William Ravelo-Méndez](https://ravelinx22.github.io/), [Camilo Escobar-Velásquez](https://caev03.github.io/), and [Mario Linares-Vásquez](https://profesores.virtual.uniandes.edu.co/mlinaresv/en/inicio-en/), *Proceedings of the 35th IEEE International Conference on Software Maintenance and Evolution ([ICSME’19](https://icsme2019.github.io/))*, Tool Demo Track, Cleveland, OH, USA, September 30th - October 4th, 2019, to appear 4 pages (52% Acceptance Rate) [[pdf](https://thesoftwaredesignlab.github.io/KrakenMobile/assets/pdfs/icsme19.pdf)][[bibtex](https://thesoftwaredesignlab.github.io/KrakenMobile/assets/pdfs/icsme19.bib)]
21
15
 
22
- Kraken uses [calabash-android](https://github.com/calabash/calabash-android) for running automated E2E tests in each device or emulator and [cucumber](https://github.com/cucumber/cucumber-ruby) for running your feature files written with Gherkin sintax.
16
+ # Technologies
23
17
 
24
- ## Installation
18
+ Kraken uses [calabash-android](https://github.com/calabash/calabash-android) and [selenium-webdriver](https://github.com/SeleniumHQ/selenium) for running automated E2E tests in each device or emulator and [cucumber](https://github.com/cucumber/cucumber-ruby) for running your feature files written with Gherkin sintax.
19
+
20
+ # 🔨 Installation
25
21
 
26
22
  ### Prerequisites
27
23
 
28
- Kraken requires Ruby 2.20 or higher but we recommend using ~2.3 version. We use calabash-android as runner, you can check their prerequisites at this [link](https://github.com/calabash/calabash-android/blob/master/documentation/installation.md)
24
+ Kraken requires Ruby 2.20 or higher but we recommend using ~2.3 version. We use calabash-android for mobile testing, you can check their prerequisites at this [link](https://github.com/calabash/calabash-android/blob/master/documentation/installation.md). For web testing we use selenium-webdriver, you can check their prerequisites as well at this [link](https://www.selenium.dev/selenium/docs/api/rb/).
25
+
26
+ - Ruby at least version 2.3.1
27
+ - Java JDK
28
+ - Android SDK
29
+ - Chromedriver (Version ~83 recommended) or Geckodriver (Only if you use Kraken web)
29
30
 
31
+ You need to have configured ANDROID_HOME, ANDROID_HOME/platform_tools and JAVA_HOME in your environment variables.
30
32
 
31
- Installing and managing a Gem is done through the gem command. To install Kraken's gem run the following command
33
+ Installing and managing Kraken Gem is done through the gem command. To install Krakens gem run the following command.
32
34
 
33
- $ gem install kraken-mobile
35
+ ```
36
+ $ gem install kraken-mobile
37
+ ```
34
38
 
39
+ NOTE: If you are having trouble running Kraken in your Windows operating system refer to the this [guide](https://github.com/TheSoftwareDesignLab/KrakenMobile/blob/master/docs/WINDOWS_GUIDE.md) specifying steps to solve this issues.
35
40
 
36
- ## Signaling
41
+ # Signaling
37
42
 
38
- Signaling is a protocol used for the communication of two or more devices running in parallel. It’s based in the idea that each emulator or real device has a communication channel where he can receive signals sent from other devices which contain information or actions that are supposed to be executed. This type of protocol is commonly used in automated mobile E2E testing tools that validate scenarios involving the inter-communication and collaboration of two or more applications.
43
+ Signaling is a protocol used for the communication of two or more devices running in parallel. It is based in the idea that each browser, emulator or real device has a communication channel where he can receive signals sent from other devices which contain information or actions that are supposed to be executed. This type of protocol is commonly used in automated mobile E2E testing tools that validate scenarios involving the inter-communication and collaboration of two or more applications.
39
44
 
40
- ## Writing your first test
45
+ # Writing your first test
41
46
 
42
47
  ### Generate cucumber feature skeleton
43
48
 
44
49
  First you need to generate the cucumber feature skeleton where your tests are going to be saved. To achieve this you should run `kraken-mobile gen`. It will create the skeleton in your current folder like this:
45
50
 
46
- features
47
- |_support
48
- | |_app_installation_hooks.rb
49
- | |_app_life_cycle_hooks.rb
50
- | |_env.rb
51
- |_step_definitions
52
- | |_kraken_steps.rb
53
- |_my_first.feature
51
+ ```
52
+ features
53
+ |_support
54
+ | |_app_installation_hooks.rb
55
+ | |_app_life_cycle_hooks.rb
56
+ | |_env.rb
57
+ |_step_definitions
58
+ | |_mobile_steps.rb
59
+ |_web
60
+ | |_step_definitions
61
+ | | |_web_steps.rb
62
+ | |_support
63
+ | | |_app_life_cycle_hooks.rb
64
+ |_my_first.feature
65
+ ```
54
66
 
55
67
  ### Write a test
56
68
 
57
- The features goes in the features foler and should have the ".feature" extension.
58
-
59
- You can start out by looking at features/my_first.feature. You should also check calabash [predefined steps](https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/canned_steps.md).
69
+ The features goes in the features foler and should have the “.feature extension. You can start out by looking at `features/my_first.feature`. You should also check calabash [predefined steps](https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/canned_steps.md).
60
70
 
61
71
  ### Syntax
62
72
 
63
- In Kraken each feature is a test and each scenario within a feature is a test case that is run in a device. Each device is identified as an user and numbered from 1 to N. Ex: @user1, @user2, @user3. To check what is the number of a given device you should run `kraken-mobile devices`
73
+ In Kraken each feature is a test and each scenario within a feature is a test case that is run in a device. Each device is identified as an user and numbered from 1 to N. Ex: @user1, @user2, @user3. To check what is the number of a given device you should run `kraken-mobile devices`.
64
74
 
65
- List of devices attached
66
- user1 - emulator-5554 - Android_SDK_built_for_x86
67
- user2 - emulator-5556 - Android_SDK_built_for_x86
75
+ ```
76
+ List of devices attached
77
+ user1 - emulator-5554 - Android_SDK_built_for_x86
78
+ user2 - emulator-5556 - Android_SDK_built_for_x86
79
+ ```
68
80
 
69
81
  After identifying what number each device has, you can write your test case giving each scenario the tag of a given device like so:
70
82
 
71
- Feature: Example feature
83
+ ```
84
+ Feature: Example feature
72
85
 
73
- @user1
74
- Scenario: As a first user I say hi to a second user
75
- Given I wait
76
- Then I send a signal to user 2 containing "hi"
86
+ @user1
87
+ Scenario: As a first user I say hi to a second user
88
+ Given I wait
89
+ Then I send a signal to user 2 containing "hi"
77
90
 
78
- @user2
79
- Scenario: As a second user I wait for user 1 to say hi
80
- Given I wait for a signal containing "hi"
81
- Then I wait
91
+ @user2
92
+ Scenario: As a second user I wait for user 1 to say hi
93
+ Given I wait for a signal containing "hi"
94
+ Then I wait
95
+ ```
82
96
 
83
- ## Kraken steps
97
+ # Kraken steps
84
98
 
85
99
  Kraken offers two main steps to help synchronizing your devices.
86
100
 
@@ -88,41 +102,139 @@ Kraken offers two main steps to help synchronizing your devices.
88
102
 
89
103
  To wait for a signal coming from another device for 10 seconds that is Kraken default timeout use the following step.
90
104
 
91
- Then /^I wait for a signal containing "([^\"]*)"$/
105
+ ```
106
+ Then /^I wait for a signal containing "([^\"]*)"$/
107
+ ```
92
108
 
93
109
  To wait for a signal coming from another device for an specified number of seconds use the following step
94
110
 
95
- Then /^I wait for a signal containing "([^\"]*)" for (\d+) seconds$/
111
+ ```
112
+ Then /^I wait for a signal containing "( [^\"]*)" for (\d+) seconds$/
113
+ ```
96
114
 
97
115
  To send a signal to another specified device use the following step
98
116
 
99
- Then /^I send a signal to user (\d+) containing "([^\"]*)"$/
117
+ ```
118
+ Then /^I send a signal to user (\d+) containing "([^\"]*)"$/
119
+ ```
100
120
 
101
121
  ### Signaling functions
102
122
 
103
- Kraken internal implementation of the signaling steps use the following functions.
104
-
105
- #### readSignal(channel, content, timeout)
123
+ Each device has an internal Kraken implementation of the signaling steps using the following functions.
106
124
 
107
- Waits for a signal with the specified content in the channel passed by parameter. This functions waits for the specified number of seconds in the timeout parameter before throwing an exception.
125
+ ```
126
+ read_signal(content, time_out)
127
+ ```
108
128
 
109
- **Note: The channel parameter has to be the number of a device such as @user1, @user2, @userN**
129
+ Waits for a signal with the specified content. This functions waits for the specified number of seconds in the timeout parameter before throwing an exception if specified.
110
130
 
111
- #### writeSignal(channel, content)
131
+ ```
132
+ write_signal(signal)
133
+ ```
112
134
 
113
- Writes content to a channel passed by parameter.
135
+ Writes signal content to a device inbox.
114
136
 
115
- **Note: The channel parameter has to be the number of a device such as @user1, @user2, @userN**
137
+ # 📱Kraken Mobile
116
138
 
117
139
  ## Running your tests
118
140
 
119
141
  To run your test:
120
142
 
121
- kraken-mobile run <apk>
143
+ ```
144
+ $ kraken-mobile run <apk>
145
+ ```
122
146
 
123
147
  Kraken with the help of Calabash-Android will install an instrumentation along with your app and will start your tests in all devices connected (Check Kraken Settings section in order to learn how to specify in what devices your tests should be run).
124
148
 
125
- ## Kraken Settings
149
+ ## 🦍 Mobile Monkey execution
150
+
151
+ Kraken offers the possibility of generating random GUI events by using Android ADB monkey as well as its own implementation based in the idea of sending and reading random signals.
152
+
153
+ ### Android’s ADB Monkey
154
+
155
+ To execute ADB monkey Kraken offers the following command specifying the number of events to be executed:
156
+
157
+ ```
158
+ Then I start a monkey with (\d+) events
159
+ ```
160
+
161
+ ### Kraken’s own monkey
162
+
163
+ Kraken extended the ADB monkey behavior by executing GUI events only in buttons and clickable views or inputs by offering the following command:
164
+
165
+ ```
166
+ Then I start kraken monkey with (\d+) events
167
+ ```
168
+
169
+ ## XML snapshot
170
+
171
+ Kraken makes it possible to save the XML presented by the current view in a specific device, this is convenient to identify view ids, asserting the correct XML is presented after an action has being completed or running static analyzing tools.
172
+
173
+ ### Saving the snapshot
174
+
175
+ To save the snapshot of the current view, Kraken offers the following step specifying where the file is going to be saved:
176
+
177
+ ```
178
+ Then I save device snapshot in file with path "([^\"]*)"
179
+ ```
180
+
181
+ # 🌎 Kraken Web
182
+
183
+ Kraken is extended to run also in web browsers and orchestrate the communication with other browsers running different websites or mobile applications that are being executed on physical devices or emulators. With the help of ChromeDriver/Geckodriver, selenium-webdriver and Cucumber we run test scenarios using Gherkin syntax as well as Kraken predefined signaling steps described before.
184
+
185
+ ## Specifying a web user in a test
186
+
187
+ To specify that user is going to be run in a web browser instead of a mobile device you need to tag the scenario with @web. If a scenario is not tagged with @web Kraken will assume that is a mobile user and will attempt to run all steps in a mobile manner.
188
+
189
+ ```bash
190
+ Feature: Example feature
191
+
192
+ @user1 @web
193
+ Scenario: As a first user I say hi to a second user
194
+ Given I navigate to page "https://www.gmail.com/"
195
+ Then I send a signal to user 2 containing "hi"
196
+
197
+ @user2 @web
198
+ Scenario: As a second user I wait for user 1 to say hi
199
+ Given I wait for a signal containing "hi"
200
+ Then I navigate to page "https://www.gmail.com/"
201
+ ```
202
+
203
+ This scenario will open two web browsers and execute the signaling between them.
204
+
205
+ ## Web steps
206
+
207
+ To see a list of all web steps available in Kraken, visit the following [link.](https://github.com/TheSoftwareDesignLab/KrakenMobile/blob/master/docs/WEB_STEPS.md)
208
+
209
+ ## Executing web only scenarios
210
+
211
+ To run a test that only contains web users and as a result does not require an APK file, run the following command:
212
+
213
+ ```
214
+ $ kraken-mobile run
215
+ ```
216
+
217
+ Kraken with the help of selenium-webdriver will start all required browsers and run your test scenario.
218
+
219
+ ## Specifying in what browser Kraken will run
220
+
221
+ Kraken uses ChromeDriver and Chrome as default web browser but provides support for Firefox and Geckodriver. To specify that your test is going to be run in Firefox, specify the environment variable BROWSER when running your tests as follows:
222
+
223
+ ```bash
224
+ $ BROWSER=firefox kraken-mobile run
225
+ ```
226
+
227
+ **Note: Make sure that you have Geckodriver and Firefox installed previously.**
228
+
229
+ ## 🦍 Web Monkey execution
230
+
231
+ Kraken has implemented it's own monkey behavior by executing random GUI events in buttons, clickable views and inputs by offering the following command:
232
+
233
+ ```
234
+ Then I start kraken monkey with (\d+) events
235
+ ```
236
+
237
+ # Kraken Settings
126
238
 
127
239
  Kraken uses kraken_mobile_settings.json to specify in what devices the tests should be run.
128
240
 
@@ -130,38 +242,102 @@ Kraken uses kraken_mobile_settings.json to specify in what devices the tests sho
130
242
 
131
243
  The following command will show you the available connected devices or emulators and let you choose which ones you want to use.
132
244
 
133
- kraken-mobile setup
245
+ ```
246
+ $ kraken-mobile setup
247
+ ```
134
248
 
135
249
  ### Run tests with settings file
136
250
 
137
- kraken-mobile run <apk> --configuration=<kraken_mobile_settings_path>
251
+ ```
252
+ $ kraken-mobile run <apk> --configuration=<kraken_mobile_settings_path>
253
+ ```
254
+
255
+ # 🗯 Extended Kraken functionalities
256
+
257
+ In the following sections we provide specification for shared functionality between Kraken mobile and web as well as some examples of Kraken in action.
138
258
 
139
- ## Properties file
259
+ # Properties file
140
260
 
141
261
  Kraken uses properties files to store sensitive data such as passwords or api keys that should be used in your test cases.
142
262
 
143
263
  ### Generate properties file
144
264
 
145
- The properties files should be a manually created json file with the following structure.
265
+ The properties files should be a manually created JSON file with the following structure.
146
266
 
147
- {
148
- "@user1": {
267
+ ```
268
+ {
269
+ "@user1": {
149
270
  "PASSWORD": "test"
150
- },
151
- "@user2": {
271
+ },
272
+ "@user2": {
152
273
  "PASSWORD": "test2"
153
- }
154
274
  }
155
-
275
+ }
276
+ ```
277
+
156
278
  ### Use properties file in your test
157
279
 
158
280
  You can use the specified properties using the following sintax.
159
281
 
160
- @user1
161
- Scenario: As a kjkhdkjds
162
- Given I wait
163
- Then I see the text "<PASSWORD>"
282
+ ```
283
+ @user1
284
+ Scenario: As a user
285
+ Given I wait
286
+ Then I see the text "<PASSWORD>"
287
+ ```
164
288
 
165
289
  ### Run tests with settings file
166
290
 
167
- kraken-mobile run <apk> --properties=<kraken_mobile_properties_path>
291
+ ```
292
+ kraken-mobile run <apk> --properties=<kraken_mobile_properties_path>
293
+ ```
294
+
295
+ # Use fake strings in tests
296
+
297
+ Kraken offers a Fake string generator thanks to the Ruby gem [Faker](https://github.com/faker-ruby/faker), the list of supported faker types are listed as follows:
298
+
299
+ - Name
300
+ - Number
301
+ - Email
302
+ - String
303
+ - String Date
304
+
305
+ ### Use a faker in a test
306
+
307
+ Kraken keeps a record of every Fake string generated, thats why each string will have an id associated. To generate a Faker string you need to follow the structure “$FAKERNAME_ID”.
308
+
309
+ ```
310
+ @user1
311
+ Scenario: As a user
312
+ Given I wait
313
+ Then I enter text "$name_1" into field with id "view"
314
+ ```
315
+
316
+ ### Reusing a fake string
317
+
318
+ As mentioned before, Kraken keeps record of every string generated with an id given to each string, this gives you the possibility of reusing this string later in your scenario. To reuse a string you can you need to append a $ character to the fake string as follows:
319
+
320
+ ```
321
+ @user1
322
+ Scenario: As a user
323
+ Given I wait
324
+ Then I enter text "$name_1" into field with id "view"
325
+ Then I press "add_button"
326
+ Then I should see "$$name_1"
327
+ ```
328
+
329
+ # Examples
330
+
331
+
332
+ | Application | Video | Feature File | Steps Definition | Properties file | Settings File | Report Link |
333
+ |:-------------|:-------------|:-------------|:------------------|:-------|:-------|:-------|
334
+ | Infinite Words | [video](https://www.youtube.com/watch?v=4lX7mO80w-4&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=3&t=0s)|[.feature](/examples/infinite-words/infinite_words.feature)|--- | --- | --- | [report](/examples/infinite-words/report/index.html) |
335
+ | QuizUp | [video](https://www.youtube.com/watch?v=2mhZVTK0r6k&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=4&t=1s) | [.feature](/examples/quizup/quizup.feature)|[stepsDef](../gh-pages/examples/quizup/step_definitions/kraken_steps.rb) | --- | --- | [report](/examples/quizup/report/index.html) |
336
+ | Spotify/Shazam | [video](https://www.youtube.com/watch?v=7AKsfY1KFX0&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=5&t=0s) | [.feature](/examples/shazam/shazam.feature)|[stepsDef](../gh-pages/examples/shazam/step_definitions/kraken_steps.rb) | [.json](/examples/shazam/kraken_properties.json) | [.json](/examples/shazam/kraken_mobile_settings.json) | [report](/examples/shazam/report/index.html) |
337
+ | Spunky | [video](https://www.youtube.com/watch?v=WOhRWkdFaVk&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=6&t=25s) | [.feature](/examples/spunky/spunky.feature)|[stepsDef](../gh-pages/examples/spunky/step_definitions/kraken_steps.rb) | --- | --- | [report](/examples/spunky/report/index.html) |
338
+ | Picap | [video](https://www.youtube.com/watch?v=RozQrmH_Z5k&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=7&t=3s) | [.feature](/examples/picap/picap.feature)|[stepsDef](../gh-pages/examples/picap/step_definitions/kraken_steps.rb) | [.json](/examples/picap/kraken_properties.json) | --- | [report](/examples/picap/report/index.html) |
339
+ | AskFM | [video](https://www.youtube.com/watch?v=d9Gbdx8kFX8&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=8&t=0s) | [.feature](/examples/askfm/askfm.feature)|[stepsDef](../gh-pages/examples/askfm/step_definitions/kraken_steps.rb) | --- | --- | [report](/examples/askfm/report/index.html) |
340
+ | Stick Men Fight | [video](https://www.youtube.com/watch?v=36OJKNj0nSo&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=9&t=4s) | [.feature](/examples/stick/stick.feature)|--- | --- | --- | [report](/examples/stick/report/index.html) |
341
+ | Tic Tac Toe | [video](https://www.youtube.com/watch?v=F9pDJDYsL_w&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=10&t=2s) | [.feature](/examples/tictactoe/tictactoe.feature)|[stepsDef](../gh-pages/examples/tictactoe/step_definitions/kraken_steps.rb) | --- | --- | [report](/examples/tictactoe/report/index.html) |
342
+ | Tumblr | [video](https://www.youtube.com/watch?v=eqFej2uJz4k&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=11&t=3s) | [.feature](/examples/tumblr/tumblr.feature)|[stepsDef](../gh-pages/examples/tumblr/step_definitions/kraken_steps.rb) | [.json](/examples/tumblr/kraken_properties.json) | --- | [report](/examples/tumblr/report/index.html) |
343
+ | F3 | [video](https://www.youtube.com/watch?v=vESh6Jyp-so&list=PLF5U8kfVgRcJ3RCHt7cWmwlqN93brbVW-&index=12&t=0s) | [.feature](/examples/f3/f3.feature)|[stepsDef](../gh-pages/examples/f3/step_definitions/kraken_steps.rb) | [.json](/examples/f3/kraken_properties.json) | --- | [report](/examples/f3/report/index.html) |
data/bin/kraken-mobile CHANGED
@@ -1,91 +1,88 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.join(File.dirname(__FILE__), "kraken-mobile-helpers")
4
- require File.join(File.dirname(__FILE__), "kraken-mobile-setup")
5
- require File.join(File.dirname(__FILE__), "kraken-mobile-calabash-android")
6
- $LOAD_PATH << File.expand_path("../../lib", __FILE__)
7
- require 'kraken-mobile'
3
+ require File.join(File.dirname(__FILE__), 'kraken_mobile_helpers')
4
+ require File.join(File.dirname(__FILE__), 'kraken_mobile_setup')
5
+ require File.join(File.dirname(__FILE__), 'kraken_mobile_calabash_android')
6
+ $LOAD_PATH << File.expand_path('../lib', __dir__)
7
+ require 'kraken_mobile'
8
8
  require 'kraken-mobile/constants'
9
9
 
10
10
  #-------------------------------
11
11
  # AGV reader helper
12
12
  #-------------------------------
13
13
 
14
- def read_specified_runner
15
- runner_command = ARGV.select { |arg| arg.include?("--runner=") }.first
16
- if runner_command
17
- formatted_runner_command = runner_command.strip.downcase
18
- formatted_runner_command.slice!("--runner=")
19
- formatted_runner_command
20
- end
21
- end
14
+ def read_configuration
15
+ configuration_command = ARGV.select do |arg|
16
+ arg.include?('--configuration=')
17
+ end.first
18
+ return if configuration_command.nil?
22
19
 
23
- def read_specified_protocol
24
- protocol_command = ARGV.select { |arg| arg.include?("--protocol=") }.first
25
- if protocol_command
26
- formatted_protocol_command = protocol_command.strip.downcase
27
- formatted_protocol_command.slice!("--protocol=")
28
- if KrakenMobile::Constants::SUPPORTED_PROTOCOLS.include?(formatted_protocol_command)
29
- formatted_protocol_command
30
- else # Protocol not supported.
31
- raise "Specified protocol not supported."
32
- end
33
- else # If protocol not specified use file based as default.
34
- KrakenMobile::Constants::FILE_PROTOCOL
35
- end
20
+ configuration_command = configuration_command.strip.downcase
21
+ configuration_command.slice!('--configuration=')
22
+ configuration_command
36
23
  end
37
24
 
38
- def read_configuration
39
- configuration_command = ARGV.select { |arg| arg.include?("--configuration=") }.first
40
- if configuration_command
41
- configuration_command = configuration_command.strip.downcase
42
- configuration_command.slice!("--configuration=")
43
- configuration_command
44
- end
25
+ def read_user_entered_properties_path
26
+ properties_command = ARGV.select { |arg| arg.include?('--properties=') }.first
27
+ return if properties_command.nil?
28
+
29
+ properties_command = properties_command.strip.downcase
30
+ properties_command.slice!('--properties=')
31
+ properties_command
45
32
  end
46
33
 
47
- def read_properties
48
- properties_command = ARGV.select { |arg| arg.include?("--properties=") }.first
49
- if properties_command
50
- properties_command = properties_command.strip.downcase
51
- properties_command.slice!("--properties=")
52
- properties_command
53
- end
34
+ #-------------------------------
35
+ # Helpers
36
+ #-------------------------------
37
+
38
+ def user_entered_apk_path
39
+ return nil if ARGV.first.nil?
40
+
41
+ first_argument = ARGV.first
42
+ return nil if first_argument.start_with?('--') # Is argument parameter not apk
43
+
44
+ File.expand_path(first_argument)
54
45
  end
55
46
 
56
47
  #-------------------------------
57
48
  # Command reader
58
49
  #-------------------------------
59
50
 
60
- if ARGV.length == 0
61
- print_usage
51
+ if ARGV.length.zero?
52
+ print_usage
62
53
  else
63
54
  cmd = ARGV.shift
64
55
  case cmd
65
- when 'version'
66
- require 'kraken-mobile/version'
67
- puts KrakenMobile::VERSION
68
- when 'devices'
69
- require 'kraken-mobile/helpers/devices_helper/manager'
70
- print_devices
71
- when 'setup'
72
- kraken_setup
73
- else
74
- runner_command = read_specified_runner()
75
- protocol = read_specified_protocol()
76
- configuration = read_configuration()
77
- properties = read_properties()
78
- if runner_command
79
- case runner_command
80
- when KrakenMobile::Constants::CALABASH_ANDROID
81
- require File.join(File.dirname(__FILE__), "kraken-mobile-calabash-android")
82
- handle_calabash_android(cmd, protocol, configuration, properties)
83
- else
84
- raise "Specified runner not supported."
85
- end
86
- else # If runner not specified use calabash android as default.
87
- require File.join(File.dirname(__FILE__), "kraken-mobile-calabash-android")
88
- handle_calabash_android(cmd, protocol, configuration, properties)
89
- end
56
+ when 'version'
57
+ require 'kraken-mobile/version'
58
+ puts KrakenMobile::VERSION
59
+ when 'devices'
60
+ require 'kraken-mobile/helpers/devices_helper/manager'
61
+ print_devices
62
+ when 'setup'
63
+ KrakenSetup.new.run
64
+ when 'gen'
65
+ ensure_java_installed
66
+ ensure_android_sdk_installed
67
+
68
+ scaffold_folder_structure
69
+ when 'resign'
70
+ ensure_java_installed
71
+ ensure_android_sdk_installed
72
+
73
+ require 'calabash-android/helpers'
74
+ puts 'Resigning APK with Calabash-Android'
75
+ ensure_apk_is_specified
76
+ resign_apk(user_entered_apk_path)
77
+ when 'run'
78
+ ensure_java_installed
79
+ ensure_android_sdk_installed
80
+
81
+ require File.join(File.dirname(__FILE__), 'kraken_mobile_calabash_android')
82
+ configuration = read_configuration
83
+ user_entered_properties_path = read_user_entered_properties_path
84
+ handle_calabash_android(configuration, user_entered_properties_path)
85
+ else
86
+ print_usage
90
87
  end
91
88
  end