11require 'kraken-mobile/device_process.rb'
2- require 'kraken-mobile/utils/k'
2+ require 'kraken-mobile/utils/k.rb '
33
44class MobileProcess < DeviceProcess
55 #-------------------------------
@@ -11,6 +11,7 @@ def before_execute
1111 end
1212
1313 def after_execute
14+ unregister_process_from_directory
1415 device . delete_inbox
1516 end
1617
@@ -42,15 +43,32 @@ def apk_path
4243 private
4344
4445 def execution_command
46+ "|#{ environment_variables_command } #{ terminal_command_separator } " \
47+ "#{ running_process_command } "
48+ end
49+
50+ def running_process_command
4551 feature_path = test_scenario . feature_file . file_path
4652 raise 'ERROR: Invalid feature file path' if feature_path . nil?
4753
4854 process_apk_path = apk_path
4955 raise 'ERROR: Invalid APK file path' if process_apk_path . nil?
5056
51- "|ADB_DEVICE_ARG=#{ device . id } calabash-android run #{ process_apk_path } " \
52- "#{ feature_path } --tags @user#{ id } --format pretty --format json -o " \
53- "#{ K ::REPORT_PATH } /#{ @test_scenario . execution_id } /#{ device . id } /#{ K ::FILE_REPORT_NAME } " # TODO, folder to save all things
57+ "calabash-android run #{ process_apk_path } \
58+ #{ feature_path } --tags @user#{ id } \
59+ --require features/support/env.rb \
60+ --require features/support/app_installation_hooks.rb \
61+ --require features/support/app_life_cycle_hooks.rb \
62+ --require features/step_definitions/mobile_steps.rb \
63+ --format pretty --format json -o \
64+ #{ K ::REPORT_PATH } /#{ @test_scenario . execution_id } /#{ device . id } /#{ K ::FILE_REPORT_NAME } "
65+ end
66+
67+ def environment_variables_command
68+ variables = {
69+ ADB_DEVICE_ARG : device . id
70+ }
71+ exporting_command_for_environment_variables ( variables )
5472 end
5573
5674 #-------------------------------
@@ -61,6 +79,7 @@ def config_json
6179 config_absolute_path = File . expand_path ( ENV [ K ::CONFIG_PATH ] )
6280 file = open ( config_absolute_path )
6381 content = file . read
82+ file . close
6483 JSON . parse ( content ) [ @id . to_s ] || { }
6584 end
6685
0 commit comments