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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- # encoding: utf-8
2
+
3
3
  module KrakenMobile
4
- VERSION = "1.0.2"
4
+ VERSION = '1.0.9'
5
5
  end
@@ -0,0 +1,41 @@
1
+ require 'kraken-mobile/device_process.rb'
2
+
3
+ class WebProcess < DeviceProcess
4
+ #-------------------------------
5
+ # Required methods
6
+ #-------------------------------
7
+ def before_execute
8
+ register_process_to_directory
9
+ device.create_inbox
10
+ end
11
+
12
+ def after_execute
13
+ unregister_process_from_directory
14
+ device.delete_inbox
15
+ end
16
+
17
+ def execute
18
+ open(execution_command, 'r') do |output|
19
+ loop do
20
+ $stdout.print output.readline.to_s
21
+ $stdout.flush
22
+ end
23
+ end
24
+ $CHILD_STATUS.exitstatus
25
+ rescue EOFError
26
+ nil
27
+ end
28
+
29
+ private
30
+
31
+ def execution_command
32
+ feature_path = test_scenario.feature_file.file_path
33
+ raise 'ERROR: Invalid feature file path' if feature_path.nil?
34
+
35
+ "|cucumber #{feature_path} --tags @user#{id} \
36
+ --require features/web/step_definitions/web_steps.rb \
37
+ --require features/web/support/app_life_cycle_hooks.rb \
38
+ --format pretty --format json -o \
39
+ #{K::REPORT_PATH}/#{@test_scenario.execution_id}/#{device.id}/#{K::FILE_REPORT_NAME}"
40
+ end
41
+ end
@@ -0,0 +1,81 @@
1
+ require 'kraken-mobile/utils/feature_reader'
2
+ require 'kraken-mobile/test_scenario'
3
+
4
+ class KrakenApp
5
+ include Utils::FeatureReader
6
+
7
+ #-------------------------------
8
+ # Fields
9
+ #-------------------------------
10
+
11
+ attr_accessor :apk_path
12
+ attr_accessor :scenarios_queue
13
+
14
+ #-------------------------------
15
+ # Constructors
16
+ #-------------------------------
17
+ def initialize(apk_path:, properties_path: nil, config_path: nil)
18
+ @apk_path = apk_path
19
+ @scenarios_queue = []
20
+ save_path_in_environment_variable_with_name(
21
+ name: K::PROPERTIES_PATH, path: properties_path
22
+ )
23
+ save_path_in_environment_variable_with_name(
24
+ name: K::CONFIG_PATH, path: config_path
25
+ )
26
+
27
+ build_scenarios_queue
28
+ end
29
+
30
+ #-------------------------------
31
+ # Observers
32
+ #-------------------------------
33
+ def on_test_scenario_finished
34
+ execute_next_scenario
35
+ end
36
+
37
+ #-------------------------------
38
+ # Helpers
39
+ #-------------------------------
40
+
41
+ def start
42
+ execute_next_scenario
43
+ end
44
+
45
+ def save_path_in_environment_variable_with_name(name:, path:)
46
+ return if path.nil?
47
+
48
+ absolute_path = File.expand_path(path)
49
+ save_value_in_environment_variable_with_name(
50
+ name: name,
51
+ value: absolute_path
52
+ )
53
+ end
54
+
55
+ def save_value_in_environment_variable_with_name(name:, value:)
56
+ return if name.nil? || value.nil?
57
+
58
+ ENV[name] = value
59
+ end
60
+
61
+ private
62
+
63
+ def build_scenarios_queue
64
+ feature_files.each do |feature_path|
65
+ scenarios_queue.unshift(
66
+ TestScenario.new(
67
+ kraken_app: self,
68
+ feature_file_path: feature_path
69
+ )
70
+ )
71
+ end
72
+ end
73
+
74
+ def execute_next_scenario
75
+ return if scenarios_queue.count.zero?
76
+
77
+ scenario = scenarios_queue.pop
78
+ scenario.run
79
+ scenario
80
+ end
81
+ end
@@ -175,7 +175,11 @@
175
175
  <%= device.model %> - <%= device.id %>
176
176
  </td>
177
177
  <td>
178
- <i class="fa fa-android fa-lg"><span>android</span></i>
178
+ <% if device.type == K::ANDROID_DEVICE %>
179
+ <i class="fa fa-android fa-lg"><span>android</span></i>
180
+ <% else %>
181
+ <i class="fa fa-globe fa-lg"><span>web</span></i>
182
+ <% end %>
179
183
  </td>
180
184
  <td>
181
185
  <%= @apk_path %>
@@ -595,18 +595,24 @@
595
595
  <div class="clearfix"></div>
596
596
  </div>
597
597
  <div class="row">
598
- <% @devices.each do |device| %>
598
+ <% devices_json.each do |device| %>
599
599
  <div class="ui-card col-md-3">
600
600
  <div class="container device-container">
601
601
  <div class="row device-os-icon">
602
- <i class="fa fa-android fa-lg"></i>
602
+ <% if device[:type] == K::ANDROID_DEVICE %>
603
+ <i class="fa fa-android fa-lg"></i>
604
+ <% else %>
605
+ <i class="fa fa-globe fa-lg"></i>
606
+ <% end %>
603
607
  </div>
604
- <div class="row device-title"><%= device['model'] %></div>
605
- <div class="row device-info">ID - <%= device['id'] %></div>
606
- <div class="row device-info">SDK Version - <%= device['sdk'] %></div>
607
- <div class="row device-info">Screen Size - <%= "#{device['screen_height']}x#{device['screen_width']}" %></div>
608
+ <div class="row device-title"><%= device[:model] %></div>
609
+ <div class="row device-info">ID - <%= device[:id] %></div>
610
+ <% if device[:type] == K::ANDROID_DEVICE %>
611
+ <div class="row device-info">SDK Version - <%= device[:sdk] %></div>
612
+ <div class="row device-info">Screen Size - <%= "#{device[:screen_height]}x#{device[:screen_width]}" %></div>
613
+ <% end %>
608
614
  <div class="row device-info result-btn">
609
- <a href='<%= "./#{device['id']}/feature_report.html" %>'>See Results</a>
615
+ <a href='<%= "./#{device[:id]}/feature_report.html" %>'>See Results</a>
610
616
  </div>
611
617
  </div>
612
618
  </div>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kraken-mobile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Ravelo M
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-31 00:00:00.000000000 Z
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -66,6 +66,62 @@ dependencies:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.18.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '11.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '11.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: capybara
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 3.31.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 3.31.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: selenium-webdriver
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 3.14.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 3.14.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: faker
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 2.10.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 2.10.0
69
125
  description: 'Automated E2E testing involving intercommunication between two or more
70
126
  mobile applications running in different devices or emulators. '
71
127
  email:
@@ -78,24 +134,39 @@ files:
78
134
  - LICENSE
79
135
  - README.md
80
136
  - bin/kraken-mobile
81
- - bin/kraken-mobile-calabash-android.rb
82
- - bin/kraken-mobile-generate.rb
83
- - bin/kraken-mobile-helpers.rb
84
- - bin/kraken-mobile-setup.rb
137
+ - bin/kraken_mobile_calabash_android.rb
138
+ - bin/kraken_mobile_helpers.rb
139
+ - bin/kraken_mobile_setup.rb
85
140
  - calabash-android-features-skeleton/my_first.feature
86
- - calabash-android-features-skeleton/step_definitions/kraken_steps.rb
141
+ - calabash-android-features-skeleton/step_definitions/mobile_steps.rb
87
142
  - calabash-android-features-skeleton/support/app_installation_hooks.rb
88
143
  - calabash-android-features-skeleton/support/app_life_cycle_hooks.rb
89
144
  - calabash-android-features-skeleton/support/env.rb
90
- - lib/kraken-mobile.rb
145
+ - calabash-android-features-skeleton/web/step_definitions/web_steps.rb
146
+ - calabash-android-features-skeleton/web/support/app_life_cycle_hooks.rb
91
147
  - lib/kraken-mobile/constants.rb
148
+ - lib/kraken-mobile/device_process.rb
92
149
  - lib/kraken-mobile/helpers/command_helper.rb
93
150
  - lib/kraken-mobile/helpers/devices_helper/adb_helper.rb
94
151
  - lib/kraken-mobile/helpers/devices_helper/manager.rb
95
152
  - lib/kraken-mobile/helpers/feature_analyzer.rb
96
153
  - lib/kraken-mobile/helpers/feature_grouper.rb
154
+ - lib/kraken-mobile/helpers/kraken_faker.rb
97
155
  - lib/kraken-mobile/helpers/reporter.rb
156
+ - lib/kraken-mobile/hooks/mobile_kraken_hooks.rb
157
+ - lib/kraken-mobile/hooks/mobile_operations.rb
158
+ - lib/kraken-mobile/hooks/web_operations.rb
159
+ - lib/kraken-mobile/mobile/adb.rb
160
+ - lib/kraken-mobile/mobile/android_commands.rb
161
+ - lib/kraken-mobile/mobile/mobile_process.rb
162
+ - lib/kraken-mobile/models/android_device.rb
98
163
  - lib/kraken-mobile/models/device.rb
164
+ - lib/kraken-mobile/models/feature_file.rb
165
+ - lib/kraken-mobile/models/feature_scenario.rb
166
+ - lib/kraken-mobile/models/web_device.rb
167
+ - lib/kraken-mobile/monkeys/mobile/android_monkey.rb
168
+ - lib/kraken-mobile/monkeys/mobile/kraken_android_monkey.rb
169
+ - lib/kraken-mobile/monkeys/web/web_monkey.rb
99
170
  - lib/kraken-mobile/protocols/file_protocol.rb
100
171
  - lib/kraken-mobile/runners/calabash/android/android_runner.rb
101
172
  - lib/kraken-mobile/runners/calabash/android/apk_signer.rb
@@ -107,7 +178,17 @@ files:
107
178
  - lib/kraken-mobile/runners/calabash/android/steps/communication_steps.rb
108
179
  - lib/kraken-mobile/runners/calabash/monkey/monkey_runner.rb
109
180
  - lib/kraken-mobile/runners/runner.rb
181
+ - lib/kraken-mobile/steps/general_steps.rb
182
+ - lib/kraken-mobile/steps/mobile/kraken_steps.rb
183
+ - lib/kraken-mobile/steps/web/kraken_steps.rb
184
+ - lib/kraken-mobile/test_scenario.rb
185
+ - lib/kraken-mobile/utils/feature_reader.rb
186
+ - lib/kraken-mobile/utils/k.rb
187
+ - lib/kraken-mobile/utils/mobile_cucumber.rb
188
+ - lib/kraken-mobile/utils/reporter.rb
110
189
  - lib/kraken-mobile/version.rb
190
+ - lib/kraken-mobile/web/web_process.rb
191
+ - lib/kraken_mobile.rb
111
192
  - reporter/assets/css/bootstrap.min.css
112
193
  - reporter/assets/css/dataTables.bootstrap.min.css
113
194
  - reporter/assets/css/feature_index.css
@@ -126,6 +207,7 @@ files:
126
207
  - reporter/assets/fonts/glyphicons-halflings-regular.woff
127
208
  - reporter/assets/fonts/glyphicons-halflings-regular.woff2
128
209
  - reporter/assets/images/kraken.png
210
+ - reporter/assets/images/krakenThumbnail.jpg
129
211
  - reporter/assets/js/Chart.min.js
130
212
  - reporter/assets/js/bootstrap.min.js
131
213
  - reporter/assets/js/d3.chart.min.js
@@ -146,7 +228,7 @@ homepage: https://github.com/TheSoftwareDesignLab/KrakenMobile
146
228
  licenses:
147
229
  - MIT
148
230
  metadata: {}
149
- post_install_message:
231
+ post_install_message:
150
232
  rdoc_options: []
151
233
  require_paths:
152
234
  - lib
@@ -161,9 +243,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
243
  - !ruby/object:Gem::Version
162
244
  version: '0'
163
245
  requirements: []
164
- rubyforge_project:
165
- rubygems_version: 2.6.14
166
- signing_key:
246
+ rubygems_version: 3.0.8
247
+ signing_key:
167
248
  specification_version: 4
168
249
  summary: Automated E2E mobile testing involving intercommunication scenarios.
169
250
  test_files: []
@@ -1,85 +0,0 @@
1
-
2
- #-------------------------------
3
- # Helpers
4
- #-------------------------------
5
- def ensure_apk_is_specified
6
- if ARGV.empty? || !is_apk_file?(ARGV.first)
7
- puts "The first parameter must be the path to a valid apk file."
8
- exit 1
9
- end
10
- end
11
-
12
- def ensure_configuration_is_valid configuration
13
- if !File.exist?(configuration) || !File.file?(configuration) || !configuration.end_with?(".json")
14
- puts "The path of the configuration file is not valid."
15
- exit 1
16
- end
17
- end
18
-
19
- def ensure_properties_is_valid properties
20
- if !File.exist?(properties) || !File.file?(properties) || !properties.end_with?(".json")
21
- puts "The path of the properties file is not valid."
22
- exit 1
23
- end
24
- end
25
-
26
- #-------------------------------
27
- # Command reader
28
- #-------------------------------
29
-
30
- @features_dir = File.join(FileUtils.pwd, "features")
31
- @support_dir = File.join(@features_dir, "support")
32
- @source_dir = File.join(File.dirname(__FILE__), '..', 'calabash-android-features-skeleton')
33
-
34
- def handle_calabash_android cmd, protocol, configuration, properties
35
- case cmd
36
- when 'gen'
37
- require File.join(File.dirname(__FILE__), "kraken-mobile-generate")
38
- kraken_scaffold()
39
- when 'resign'
40
- require 'calabash-android/helpers'
41
- ensure_apk_is_specified
42
- puts "Resigning APK with Calabash-Android"
43
- resign_apk(File.expand_path(ARGV.first))
44
- when 'monkey'
45
- require 'kraken-mobile/constants'
46
- require 'calabash-android/helpers'
47
- options = {
48
- runner: KrakenMobile::Constants::MONKEY,
49
- }
50
- if configuration
51
- ensure_configuration_is_valid File.expand_path(configuration)
52
- options[:config_path] = File.expand_path(configuration)
53
- else
54
- ensure_apk_is_specified
55
- options[:apk_path] = ARGV.first
56
- end
57
- # NOT AVAILABLE
58
- #kraken = KrakenMobile::App.new(options)
59
- #kraken.run_in_parallel
60
- when 'run'
61
- require 'kraken-mobile/constants'
62
- require 'calabash-android/helpers'
63
- options = {
64
- feature_folder: @features_dir,
65
- runner: KrakenMobile::Constants::CALABASH_ANDROID,
66
- protocol: protocol
67
- }
68
- if configuration
69
- ensure_configuration_is_valid File.expand_path(configuration)
70
- options[:config_path] = File.expand_path(configuration)
71
- else
72
- ensure_apk_is_specified
73
- options[:apk_path] = ARGV.first
74
- end
75
- if properties
76
- ensure_properties_is_valid File.expand_path(properties)
77
- options[:properties_path] = File.expand_path(properties)
78
- end
79
- kraken = KrakenMobile::App.new(options)
80
- kraken.run_in_parallel
81
- else
82
- puts "Invalid command '#{cmd}'"
83
- print_usage
84
- end
85
- end
@@ -1,19 +0,0 @@
1
- def kraken_scaffold
2
- if File.exists?(@features_dir)
3
- puts "A features directory already exists. Stopping..."
4
- exit 1
5
- end
6
- msg("Question") do
7
- puts "I'm about to create a subdirectory called features."
8
- puts "features will contain all your kraken tests."
9
- puts "Please hit return to confirm that's what you want."
10
- end
11
- exit 2 unless STDIN.gets.chomp == ''
12
-
13
- FileUtils.cp_r(@source_dir, @features_dir)
14
-
15
- msg("Info") do
16
- puts "features subdirectory created. \n"
17
- end
18
-
19
- end