kraken-mobile 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +45 -11
  3. data/bin/kraken-mobile +55 -67
  4. data/bin/kraken_mobile_calabash_android.rb +39 -0
  5. data/bin/kraken_mobile_helpers.rb +91 -0
  6. data/bin/kraken_mobile_setup.rb +134 -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 +94 -0
  14. data/lib/kraken-mobile/helpers/devices_helper/adb_helper.rb +100 -105
  15. data/lib/kraken-mobile/helpers/kraken_faker.rb +107 -0
  16. data/lib/kraken-mobile/hooks/mobile_kraken_hooks.rb +15 -0
  17. data/lib/kraken-mobile/hooks/mobile_operations.rb +36 -0
  18. data/lib/kraken-mobile/hooks/web_operations.rb +33 -0
  19. data/lib/kraken-mobile/mobile/adb.rb +66 -0
  20. data/lib/kraken-mobile/mobile/android_commands.rb +43 -0
  21. data/lib/kraken-mobile/mobile/mobile_process.rb +82 -0
  22. data/lib/kraken-mobile/models/android_device.rb +121 -0
  23. data/lib/kraken-mobile/models/device.rb +113 -31
  24. data/lib/kraken-mobile/models/feature_file.rb +108 -0
  25. data/lib/kraken-mobile/models/feature_scenario.rb +24 -0
  26. data/lib/kraken-mobile/models/web_device.rb +86 -0
  27. data/lib/kraken-mobile/monkeys/mobile/android_monkey.rb +30 -0
  28. data/lib/kraken-mobile/monkeys/mobile/kraken_android_monkey.rb +54 -0
  29. data/lib/kraken-mobile/runners/calabash/android/steps/communication_steps.rb +15 -0
  30. data/lib/kraken-mobile/steps/general_steps.rb +82 -0
  31. data/lib/kraken-mobile/steps/mobile/kraken_steps.rb +72 -0
  32. data/lib/kraken-mobile/steps/web/kraken_steps.rb +81 -0
  33. data/lib/kraken-mobile/test_scenario.rb +193 -0
  34. data/lib/kraken-mobile/utils/feature_reader.rb +17 -0
  35. data/lib/kraken-mobile/utils/k.rb +67 -0
  36. data/lib/kraken-mobile/utils/mobile_cucumber.rb +2 -0
  37. data/lib/kraken-mobile/utils/reporter.rb +453 -0
  38. data/lib/kraken-mobile/version.rb +2 -2
  39. data/lib/kraken-mobile/web/web_process.rb +39 -0
  40. data/lib/kraken_mobile.rb +77 -0
  41. data/reporter/index.html.erb +6 -6
  42. metadata +89 -9
  43. data/bin/kraken-mobile-calabash-android.rb +0 -85
  44. data/bin/kraken-mobile-generate.rb +0 -19
  45. data/bin/kraken-mobile-helpers.rb +0 -48
  46. data/bin/kraken-mobile-setup.rb +0 -50
  47. data/calabash-android-features-skeleton/step_definitions/kraken_steps.rb +0 -1
  48. 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.4"
4
+ VERSION = '1.0.5'
5
5
  end
@@ -0,0 +1,39 @@
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
+ device.delete_inbox
14
+ end
15
+
16
+ def execute
17
+ open(execution_command, 'r') do |output|
18
+ loop do
19
+ $stdout.print output.readline.to_s
20
+ $stdout.flush
21
+ end
22
+ end
23
+ $CHILD_STATUS.exitstatus
24
+ rescue EOFError
25
+ nil
26
+ end
27
+
28
+ private
29
+
30
+ def execution_command
31
+ feature_path = test_scenario.feature_file.file_path
32
+ raise 'ERROR: Invalid feature file path' if feature_path.nil?
33
+
34
+ # TODO, only execute one file
35
+ "|cucumber --tags @user#{id}\
36
+ --require features/web/step_definitions/web_steps.rb \
37
+ --require features/web/support/app_life_cycle_hooks.rb"
38
+ end
39
+ end
@@ -0,0 +1,77 @@
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
+ def start
31
+ execute_next_scenario
32
+ end
33
+
34
+ #-------------------------------
35
+ # Observers
36
+ #-------------------------------
37
+ def on_test_scenario_finished
38
+ execute_next_scenario
39
+ end
40
+
41
+ private
42
+
43
+ def build_scenarios_queue
44
+ feature_files.each do |feature_path|
45
+ scenarios_queue.unshift(
46
+ TestScenario.new(
47
+ kraken_app: self,
48
+ feature_file_path: feature_path
49
+ )
50
+ )
51
+ end
52
+ end
53
+
54
+ def execute_next_scenario
55
+ return if scenarios_queue.count.zero?
56
+
57
+ scenario = scenarios_queue.pop
58
+ scenario.run
59
+ scenario
60
+ end
61
+
62
+ def save_path_in_environment_variable_with_name(name:, path:)
63
+ return if path.nil?
64
+
65
+ absolute_path = File.expand_path(path)
66
+ save_value_in_environmant_variable_with_name(
67
+ name: name,
68
+ value: absolute_path
69
+ )
70
+ end
71
+
72
+ def save_value_in_environmant_variable_with_name(name:, value:)
73
+ return if name.nil? || value.nil?
74
+
75
+ ENV[name] = value
76
+ end
77
+ end
@@ -595,18 +595,18 @@
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
602
  <i class="fa fa-android fa-lg"></i>
603
603
  </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>
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
608
  <div class="row device-info result-btn">
609
- <a href='<%= "./#{device['id']}/feature_report.html" %>'>See Results</a>
609
+ <a href='<%= "./#{device[:id]}/feature_report.html" %>'>See Results</a>
610
610
  </div>
611
611
  </div>
612
612
  </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.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Ravelo M
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-26 00:00:00.000000000 Z
11
+ date: 2020-03-20 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.142.7
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 3.142.7
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,38 @@ 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
99
169
  - lib/kraken-mobile/protocols/file_protocol.rb
100
170
  - lib/kraken-mobile/runners/calabash/android/android_runner.rb
101
171
  - lib/kraken-mobile/runners/calabash/android/apk_signer.rb
@@ -107,7 +177,17 @@ files:
107
177
  - lib/kraken-mobile/runners/calabash/android/steps/communication_steps.rb
108
178
  - lib/kraken-mobile/runners/calabash/monkey/monkey_runner.rb
109
179
  - lib/kraken-mobile/runners/runner.rb
180
+ - lib/kraken-mobile/steps/general_steps.rb
181
+ - lib/kraken-mobile/steps/mobile/kraken_steps.rb
182
+ - lib/kraken-mobile/steps/web/kraken_steps.rb
183
+ - lib/kraken-mobile/test_scenario.rb
184
+ - lib/kraken-mobile/utils/feature_reader.rb
185
+ - lib/kraken-mobile/utils/k.rb
186
+ - lib/kraken-mobile/utils/mobile_cucumber.rb
187
+ - lib/kraken-mobile/utils/reporter.rb
110
188
  - lib/kraken-mobile/version.rb
189
+ - lib/kraken-mobile/web/web_process.rb
190
+ - lib/kraken_mobile.rb
111
191
  - reporter/assets/css/bootstrap.min.css
112
192
  - reporter/assets/css/dataTables.bootstrap.min.css
113
193
  - reporter/assets/css/feature_index.css
@@ -162,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
242
  - !ruby/object:Gem::Version
163
243
  version: '0'
164
244
  requirements: []
165
- rubygems_version: 3.0.4
245
+ rubygems_version: 3.0.6
166
246
  signing_key:
167
247
  specification_version: 4
168
248
  summary: Automated E2E mobile testing involving intercommunication scenarios.
@@ -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
@@ -1,48 +0,0 @@
1
- require "rubygems"
2
- require 'fileutils'
3
-
4
- #-------------------------------
5
- # Helpers
6
- #-------------------------------
7
-
8
- def print_usage
9
- puts <<EOF
10
- Usage: kraken-mobile <command-name> [parameters] [options]
11
- <command-name> can be one of
12
- run <apk>
13
- runs Cucumber in the current folder with the environment needed.
14
- version
15
- prints the gem version.
16
- devices
17
- prints the list of devices attached.
18
- setup
19
- creates kraken-settings file specifying in what devices the tests are going to be run.
20
- gen
21
- generate a features folder structure.
22
- resign <apk>
23
- resigns the app with the currently configured keystore.
24
- EOF
25
- end
26
-
27
- def print_devices
28
- runner = KrakenMobile::Constants::CALABASH_ANDROID
29
- device_manager = KrakenMobile::DevicesHelper::Manager.new({runner: runner})
30
- puts "List of devices attached"
31
- device_manager.connected_devices.each_with_index do |device, index|
32
- puts "user#{index+1} - #{device.id} - #{device.model}"
33
- end
34
- end
35
-
36
- def is_apk_file?(file_path)
37
- file_path.end_with? ".apk" and File.exist? file_path
38
- end
39
-
40
- def relative_to_full_path(file_path)
41
- File.expand_path(file_path)
42
- end
43
-
44
- def msg(title, &block)
45
- puts "\n" + "-"*10 + title + "-"*10
46
- block.call
47
- puts "-"*10 + "-------" + "-"*10 + "\n"
48
- end