Class: FastlaneFlutterFlavor::IntegrationTest
- Inherits:
-
Object
- Object
- FastlaneFlutterFlavor::IntegrationTest
- Defined in:
- lib/fastlane/plugin/ann_flutter_flavor/helper/test_integration.rb
Overview
IntegrationTest (Helper Class)
Instance Method Summary collapse
- #cleanup ⇒ Object
- #closeEmulators(options:) ⇒ Object
-
#initialize(lane:, isAndroid:, isIos:, test_spec_file:, statusManager:, root_folder:) ⇒ IntegrationTest
constructor
Added root_folder.
- #openEmulators(options:) ⇒ Object
- #runTests(flavor: nil, emulator: nil, open_emulator: true, close_emulator: true, wipe_data: true, skip_screenshots: nil, skip_sound_null_safety: false) ⇒ Object
Constructor Details
#initialize(lane:, isAndroid:, isIos:, test_spec_file:, statusManager:, root_folder:) ⇒ IntegrationTest
Added root_folder
12 13 14 15 16 17 18 19 20 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/test_integration.rb', line 12 def initialize(lane: , isAndroid: , isIos: , test_spec_file: , statusManager:, root_folder:) # Added root_folder @lane = lane @isAndroid = isAndroid @isIos = isIos @test_spec_file = test_spec_file @loaded = false @statusManager = statusManager @root_folder = root_folder # Store root folder end |
Instance Method Details
#cleanup ⇒ Object
22 23 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/test_integration.rb', line 22 def cleanup end |
#closeEmulators(options:) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/test_integration.rb', line 41 def closeEmulators(options: ) load_file() @emulators.each_pair { |emulator,port| if emulator == .fetch(:emulator, emulator) if @isAndroid closeAndroidEmulator(emulatorName: emulator, port: port) elsif @isIos closeIosEmulator(emulatorName: emulator) end end } end |
#openEmulators(options:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/test_integration.rb', line 25 def openEmulators(options: ) load_file() @emulators.each_pair { |emulator,port| if emulator == .fetch(:emulator, emulator) wipe_data = .fetch(:wipe_data, true) if @isAndroid openAndroidEmulator(emulatorName: emulator, port: port, wipe_data: wipe_data, dns_server: .fetch(:dns_server, "")) elsif @isIos openIosEmulator(emulatorName: emulator, wipe_data: wipe_data) end end } end |
#runTests(flavor: nil, emulator: nil, open_emulator: true, close_emulator: true, wipe_data: true, skip_screenshots: nil, skip_sound_null_safety: false) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/fastlane/plugin/ann_flutter_flavor/helper/test_integration.rb', line 56 def runTests(flavor: nil, emulator: nil, open_emulator: true, close_emulator: true, wipe_data: true, skip_screenshots: nil, skip_sound_null_safety: false) load_file() openedEmulator = {} # Determine target emulators: nil => all; string (comma-separated) or array => only those entries target_emulators = if emulator.nil? @emulators else emulators_list = emulator.is_a?(String) ? emulator.split(",").map(&:strip) : Array(emulator) found = emulators_list.select { |e| @emulators.key?(e) } missing = emulators_list - found if missing.any? Fastlane::UI.error("Emulator(s) not found in the test spec: #{missing.join(', ')}. Available: #{@emulators.keys.join(', ')}") end if found.empty? Fastlane::UI.error("None of the specified emulators were found. Aborting runTests.") return end @emulators.select { |k,_| found.include?(k) } end target_emulators.each_pair { |emulator_name, port| # already limited to chosen emulators; treat as valid isValidEmulator = true isEmulatorAlreadyOpen = openedEmulator.fetch(emulator_name, false) if open_emulator && isValidEmulator && !isEmulatorAlreadyOpen if @isAndroid openAndroidEmulator(emulatorName: emulator_name, port: port, wipe_data: wipe_data, dns_server: "") elsif @isIos openIosEmulator(emulatorName: emulator_name, wipe_data: wipe_data) end openedEmulator[emulator_name] = true end @flavorDevices.each_pair { |key,value| device = key[0] flavor_name = key[1] next unless emulator_name == device # Determine which flavors to run: if a filter was provided use it, otherwise default to the flavor from the spec flavors = if flavor.nil? [flavor_name] else flavor.split(",") end isValidFlavor = flavors.include?(flavor_name) next unless isValidFlavor deviceName = device if @isAndroid deviceName = "emulator-#{port}" end test_cases = value['tests'] test_cases.each_pair { |testcaseName,parameters| begin resolved_skip_screenshots = skip_screenshots.nil? ? !@enable_screenshots : skip_screenshots runTest( driver_file: value['driver_file'], test_file: value['test_file'], device_id: deviceName, flavor: flavor_name, testcase_name: testcaseName, parameters: parameters, skip_screenshots: resolved_skip_screenshots, skip_sound_null_safety: skip_sound_null_safety ) @statusManager.logSuccess flavor_name, "runTests", emulator_name rescue => e Fastlane::UI.error "Error while running tests for flavor #{flavor_name}" @statusManager.logError flavor_name, "runTests", emulator_name, e end } } if close_emulator && isValidEmulator if @isAndroid closeAndroidEmulator(emulatorName: emulator_name, port: port) elsif @isIos closeIosEmulator(emulatorName: emulator_name) end openedEmulator[emulator_name] = false end } end |