How to use shutdown method of Test Package

Best Minitest_ruby code snippet using Test.shutdown

test_command_generator_spec.rb

Source:test_command_generator_spec.rb Github

copy

Full Screen

1describe Scan do2 before(:all) do3 options = { project: "./scan/examples/standard/app.xcodeproj" }4 config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)5 @project = FastlaneCore::Project.new(config)6 end7 before(:each) do8 @valid_simulators = "== Devices ==9-- iOS 10.0 --10 iPhone 5 (5FF87891-D7CB-4C65-9F88-701A471223A9) (Shutdown)11 iPhone 5s (E697990C-3A83-4C01-83D1-C367011B31EE) (Shutdown)12 iPhone 6 (A35509F5-78A4-4B7D-B199-0F1244A5A7FC) (Shutdown)13 iPhone 6 Plus (F8E78DE1-F715-46BE-B9FD-4909CC45C05F) (Shutdown)14 iPhone 6s (021A465B-A294-4D9E-AD07-6BDC8E186343) (Shutdown)15 iPhone 6s Plus (1891208D-477A-4399-83BE-7D57B176A32B) (Shutdown)16 iPhone SE (B3D411C0-7FC4-4248-BEB8-7B09668023C8) (Shutdown)17 iPad Retina (07773A11-417D-4D4C-BC25-1C3444D50836) (Shutdown)18 iPad Air (2ABEAF08-E480-4617-894F-6BAB587E7963) (Shutdown)19 iPad Air 2 (DA6C7D10-564B-4563-884D-834EF4F10FB9) (Shutdown)20 iPad Pro (9.7-inch) (C051C63B-EDF7-4871-860A-BF975B517E94) (Shutdown)21 iPad Pro (12.9-inch) (EED6BFB4-5DD9-48AB-8573-5172EF6F2A93) (Shutdown)22-- iOS 9.3 --23 iPhone 4s (238767C4-AF29-4485-878C-7011B98DCB87) (Shutdown)24 iPhone 5 (B8E05CCB-B97A-41FC-A8A8-2771711690B5) (Shutdown)25 iPhone 5s (F48E1168-110C-4EC6-805C-6B03A03CAC2D) (Shutdown)26 iPhone 6 (BD0777BE-32DC-425F-8FC6-10008F7AB814) (Shutdown)27 iPhone 6 Plus (E9F12F3C-75B9-47D0-998A-02220E1E7E9D) (Shutdown)28 iPhone 6s (70E1E92F-A292-4980-BC3C-7770C5EEFCFD) (Shutdown)29 iPhone 6s Plus (A250CEDA-5CCD-4396-B215-19AF6D0B4ADA) (Shutdown)30 iPad 2 (57344451-50CF-40E1-96FA-DFEFC1107B79) (Shutdown)31 iPad Retina (AD4384AC-3D47-4B43-B0E2-2020C41D67F5) (Shutdown)32 iPad Air (DD134998-177F-47DA-99FA-D549D9305476) (Shutdown)33 iPad Air 2 (9B54C167-21A9-4AD7-97D4-21F2F1D7EAAF) (Shutdown)34 iPad Pro (61EEEF5C-EA64-47EF-9EED-3075E983FBCD) (Shutdown)35-- iOS 9.0 --36 iPhone 4s (88975B7F-DE3C-4680-8653-F4212E389E35) (Shutdown)37 iPhone 5 (9905A018-9DC9-4DD8-BA14-B0B000CC8622) (Shutdown)38 iPhone 5s (FD90588B-1020-45C5-8EE9-C5CF89A26A22) (Shutdown)39 iPhone 6 (9A224332-DF90-4A30-BB7B-D0ABFE2A658F) (Shutdown)40 iPhone 6 Plus (B12E4F8A-00DF-4DFA-AF0F-FCAD6C16CBDE) (Shutdown)41 iPad 2 (A9B8647B-1C6C-41D5-8B51-B2D0A7FD4549) (Shutdown)42 iPad Retina (39EAB2A5-FBF8-417C-9578-4C47125E6658) (Shutdown)43 iPad Air (1D37AF01-FA0A-485A-86CD-A5F26845C528) (Shutdown)44 iPad Air 2 (90FF95A9-CB0E-4670-B9C4-A9BC6500F4EA) (Shutdown)45-- iOS 8.4 --46 iPhone 4s (16764BF6-4E85-42CE-9C1E-E5B0185B49BD) (Shutdown)47 iPhone 5 (6636AA80-6030-468A-8650-479A1A11899A) (Shutdown)48 iPhone 5s (5E15A2AC-2787-4C8D-8FBA-DF09FD216326) (Shutdown)49 iPhone 6 (9842E17B-F831-4CEE-BF7A-90EC14A346B7) (Shutdown)50 iPhone 6 Plus (6B638BF3-773A-4604-BB4A-75C33138C371) (Shutdown)51 iPad 2 (D15D74A7-338D-4CCC-9FE4-158917220903) (Shutdown)52 iPad Retina (3482DB34-48FE-4166-9C85-C30042E82DFE) (Shutdown)53 iPad Air (CF1146F7-9C3C-490A-B41C-38D0674333E6) (Shutdown)54-- tvOS 9.2 --55 Apple TV 1080p (83C3BAF8-54AD-4403-A688-D0B6E58020AF) (Shutdown)56-- watchOS 2.2 --57 Apple Watch - 38mm (779DA803-15AF-4E18-86B1-F4BF94547891) (Shutdown)58 Apple Watch - 42mm (A6371161-FEEA-46E2-9382-0DB41C85FA70) (Shutdown)59"60 FastlaneCore::Simulator.clear_cache61 response = "response"62 allow(response).to receive(:read).and_return(@valid_simulators)63 allow(Open3).to receive(:popen3).with("xcrun simctl list devices").and_yield(nil, response, nil, nil)64 rt_response = ""65 allow(rt_response).to receive(:read).and_return("no\n")66 allow(Open3).to receive(:popen3).with("xcrun simctl list runtimes").and_yield(nil, rt_response, nil, nil)67 allow(FastlaneCore::CommandExecutor).to receive(:execute).with(command: "sw_vers -productVersion", print_all: false, print_command: false).and_return('10.12.1')68 allow(Scan).to receive(:project).and_return(@project)69 end70 describe Scan::TestCommandGenerator do71 before(:each) do72 @test_command_generator = Scan::TestCommandGenerator.new73 end74 it "raises an exception when project path wasn't found" do75 expect do76 options = { project: "/notExistent" }77 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)78 end.to raise_error("Project file not found at path '/notExistent'")79 end80 describe "Supports toolchain" do81 it "should fail if :xctestrun and :toolchain is set" do82 allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(".")83 expect do84 Fastlane::FastFile.new.parse("lane :test do85 scan(86 project: './scan/examples/standard/app.xcodeproj',87 xctestrun: './path/1.xctestrun',88 toolchain: 'com.apple.dt.toolchain.Swift_2_3'89 )90 end").runner.execute(:test)91 end.to raise_error("Unresolved conflict between options: 'toolchain' and 'xctestrun'")92 end93 it "passes the toolchain option to xcodebuild", requires_xcodebuild: true do94 options = { project: "./scan/examples/standard/app.xcodeproj", sdk: "9.0", toolchain: "com.apple.dt.toolchain.Swift_2_3" }95 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)96 result = @test_command_generator.generate97 expect(result).to start_with([98 "set -o pipefail &&",99 "env NSUnbufferedIO=YES xcodebuild",100 "-scheme app",101 "-project ./scan/examples/standard/app.xcodeproj",102 "-sdk '9.0'",103 "-destination 'platform=iOS Simulator,id=E697990C-3A83-4C01-83D1-C367011B31EE'",104 "-toolchain 'com.apple.dt.toolchain.Swift_2_3'",105 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",106 :build,107 :test108 ])109 end110 end111 it "supports additional parameters", requires_xcodebuild: true do112 log_path = File.expand_path("~/Library/Logs/scan/app-app.log")113 xcargs = { DEBUG: "1", BUNDLE_NAME: "Example App" }114 options = { project: "./scan/examples/standard/app.xcodeproj", sdk: "9.0", xcargs: xcargs }115 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)116 result = @test_command_generator.generate117 expect(result).to start_with([118 "set -o pipefail &&",119 "env NSUnbufferedIO=YES xcodebuild",120 "-scheme app",121 "-project ./scan/examples/standard/app.xcodeproj",122 "-sdk '9.0'",123 "-destination 'platform=iOS Simulator,id=E697990C-3A83-4C01-83D1-C367011B31EE'",124 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",125 "DEBUG=1 BUNDLE_NAME=Example\\ App",126 :build,127 :test128 ])129 end130 it "supports custom xcpretty formatter", requires_xcodebuild: true do131 options = { formatter: "custom-formatter", project: "./scan/examples/standard/app.xcodeproj", sdk: "9.0" }132 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)133 result = @test_command_generator.generate134 expect(result.last).to include("| xcpretty -f `custom-formatter`")135 end136 describe "Standard Example" do137 before do138 options = { project: "./scan/examples/standard/app.xcodeproj" }139 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)140 end141 it "uses the correct build command with the example project with no additional parameters", requires_xcodebuild: true do142 log_path = File.expand_path("~/Library/Logs/scan/app-app.log")143 result = @test_command_generator.generate144 expect(result).to start_with([145 "set -o pipefail &&",146 "env NSUnbufferedIO=YES xcodebuild",147 "-scheme app",148 "-project ./scan/examples/standard/app.xcodeproj",149 "-destination 'platform=iOS Simulator,id=E697990C-3A83-4C01-83D1-C367011B31EE'",150 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",151 :build,152 :test153 ])154 end155 it "#project_path_array", requires_xcodebuild: true do156 result = @test_command_generator.project_path_array157 expect(result).to eq(["-scheme app", "-project ./scan/examples/standard/app.xcodeproj"])158 end159 it "#build_path", requires_xcodebuild: true do160 result = @test_command_generator.build_path161 regex = %r{Library/Developer/Xcode/Archives/\d\d\d\d\-\d\d\-\d\d}162 expect(result).to match(regex)163 end164 it "#buildlog_path is used when provided", requires_xcodebuild: true do165 options = { project: "./scan/examples/standard/app.xcodeproj", buildlog_path: "/tmp/my/path" }166 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)167 result = @test_command_generator.xcodebuild_log_path168 expect(result).to include("/tmp/my/path")169 end170 it "#buildlog_path is not used when not provided", requires_xcodebuild: true do171 result = @test_command_generator.xcodebuild_log_path172 expect(result.to_s).to include(File.expand_path("#{FastlaneCore::Helper.buildlog_path}/scan"))173 end174 end175 describe "Derived Data Example" do176 before do177 options = { project: "./scan/examples/standard/app.xcodeproj", derived_data_path: "/tmp/my/derived_data" }178 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)179 end180 it "uses the correct build command with the example project", requires_xcodebuild: true do181 log_path = File.expand_path("~/Library/Logs/scan/app-app.log")182 result = @test_command_generator.generate183 expect(result).to start_with([184 "set -o pipefail &&",185 "env NSUnbufferedIO=YES xcodebuild",186 "-scheme app",187 "-project ./scan/examples/standard/app.xcodeproj",188 "-destination 'platform=iOS Simulator,id=E697990C-3A83-4C01-83D1-C367011B31EE'",189 "-derivedDataPath '/tmp/my/derived_data'",190 :build,191 :test192 ])193 end194 end195 describe "with Scan option :include_simulator_logs" do196 context "extract system.logarchive" do197 it "copies all device logs to the output directory", requires_xcodebuild: true do198 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, {199 output_directory: '/tmp/scan_results',200 include_simulator_logs: true,201 devices: ["iPhone 6s", "iPad Air"],202 project: './scan/examples/standard/app.xcodeproj'203 })204 Scan.cache[:temp_junit_report] = './scan/spec/fixtures/boring.log'205 expect(FastlaneCore::CommandExecutor).206 to receive(:execute).207 with(command: "xcrun simctl spawn 021A465B-A294-4D9E-AD07-6BDC8E186343 log collect --output /tmp/scan_results/system_logs-iPhone\\ 6s_iOS_10.0.logarchive 2>/dev/null", print_all: false, print_command: true)208 expect(FastlaneCore::CommandExecutor).209 to receive(:execute).210 with(command: "xcrun simctl spawn 2ABEAF08-E480-4617-894F-6BAB587E7963 log collect --output /tmp/scan_results/system_logs-iPad\\ Air_iOS_10.0.logarchive 2>/dev/null", print_all: false, print_command: true)211 mock_test_result_parser = Object.new212 allow(Scan::TestResultParser).to receive(:new).and_return(mock_test_result_parser)213 allow(mock_test_result_parser).to receive(:parse_result).and_return({ tests: 100, failures: 0 })214 mock_slack_poster = Object.new215 allow(Scan::SlackPoster).to receive(:new).and_return(mock_slack_poster)216 allow(mock_slack_poster).to receive(:run)217 mock_test_command_generator = Object.new218 allow(Scan::TestCommandGenerator).to receive(:new).and_return(mock_test_command_generator)219 allow(mock_test_command_generator).to receive(:xcodebuild_log_path).and_return('./scan/spec/fixtures/boring.log')220 Scan::Runner.new.handle_results(0)221 end222 end223 end224 describe "Result Bundle Example" do225 it "uses the correct build command with the example project", requires_xcodebuild: true do226 log_path = File.expand_path("~/Library/Logs/scan/app-app.log")227 options = { project: "./scan/examples/standard/app.xcodeproj", result_bundle: true, scheme: 'app' }228 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)229 result = @test_command_generator.generate230 expect(result).to start_with([231 "set -o pipefail &&",232 "env NSUnbufferedIO=YES xcodebuild",233 "-scheme app",234 "-project ./scan/examples/standard/app.xcodeproj",235 "-destination 'platform=iOS Simulator,id=E697990C-3A83-4C01-83D1-C367011B31EE'",236 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",237 "-resultBundlePath './fastlane/test_output/app.test_result'",238 :build,239 :test240 ])241 end242 end243 describe "Test Exclusion Example" do244 it "only tests the test bundle/suite/cases specified in only_testing when the input is an array", requires_xcodebuild: true do245 log_path = File.expand_path("~/Library/Logs/scan/app-app.log")246 options = { project: "./scan/examples/standard/app.xcodeproj", scheme: 'app',247 only_testing: %w(TestBundleA/TestSuiteB TestBundleC) }248 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)249 result = @test_command_generator.generate250 expect(result).to start_with([251 "set -o pipefail &&",252 "env NSUnbufferedIO=YES xcodebuild",253 "-scheme app",254 "-project ./scan/examples/standard/app.xcodeproj",255 "-destination 'platform=iOS Simulator,id=E697990C-3A83-4C01-83D1-C367011B31EE'",256 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",257 '-only-testing:TestBundleA/TestSuiteB',258 '-only-testing:TestBundleC',259 :build,260 :test261 ])262 end263 it "only tests the test bundle/suite/cases specified in only_testing when the input is a string", requires_xcodebuild: true do264 log_path = File.expand_path("~/Library/Logs/scan/app-app.log")265 options = { project: "./scan/examples/standard/app.xcodeproj", scheme: 'app',266 only_testing: 'TestBundleA/TestSuiteB' }267 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)268 result = @test_command_generator.generate269 expect(result).to start_with([270 "set -o pipefail &&",271 "env NSUnbufferedIO=YES xcodebuild",272 "-scheme app",273 "-project ./scan/examples/standard/app.xcodeproj",274 "-destination 'platform=iOS Simulator,id=E697990C-3A83-4C01-83D1-C367011B31EE'",275 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",276 '-only-testing:TestBundleA/TestSuiteB',277 :build,278 :test279 ])280 end281 it "does not the test bundle/suite/cases specified in skip_testing when the input is an array", requires_xcodebuild: true do282 log_path = File.expand_path("~/Library/Logs/scan/app-app.log")283 options = { project: "./scan/examples/standard/app.xcodeproj", scheme: 'app',284 skip_testing: %w(TestBundleA/TestSuiteB TestBundleC) }285 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)286 result = @test_command_generator.generate287 expect(result).to start_with([288 "set -o pipefail &&",289 "env NSUnbufferedIO=YES xcodebuild",290 "-scheme app",291 "-project ./scan/examples/standard/app.xcodeproj",292 "-destination 'platform=iOS Simulator,id=E697990C-3A83-4C01-83D1-C367011B31EE'",293 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",294 '-skip-testing:TestBundleA/TestSuiteB',295 '-skip-testing:TestBundleC',296 :build,297 :test298 ])299 end300 it "does not the test bundle/suite/cases specified in skip_testing when the input is a string", requires_xcodebuild: true do301 log_path = File.expand_path("~/Library/Logs/scan/app-app.log")302 options = { project: "./scan/examples/standard/app.xcodeproj", scheme: 'app',303 skip_testing: 'TestBundleA/TestSuiteB' }304 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)305 result = @test_command_generator.generate306 expect(result).to start_with([307 "set -o pipefail &&",308 "env NSUnbufferedIO=YES xcodebuild",309 "-scheme app",310 "-project ./scan/examples/standard/app.xcodeproj",311 "-destination 'platform=iOS Simulator,id=E697990C-3A83-4C01-83D1-C367011B31EE'",312 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",313 '-skip-testing:TestBundleA/TestSuiteB',314 :build,315 :test316 ])317 end318 end319 it "uses a device without version specifier", requires_xcodebuild: true do320 options = { project: "./scan/examples/standard/app.xcodeproj", device: "iPhone 6s" }321 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)322 result = @test_command_generator.generate323 expect(result).to start_with([324 "set -o pipefail &&",325 "env NSUnbufferedIO=YES xcodebuild",326 "-scheme app",327 "-project ./scan/examples/standard/app.xcodeproj",328 # expect the single highest versioned iOS simulator device available with matching name329 "-destination 'platform=iOS Simulator,id=021A465B-A294-4D9E-AD07-6BDC8E186343'",330 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",331 :build,332 :test333 ])334 end335 it "rejects devices with versions below deployment target", requires_xcodebuild: true do336 options = { project: "./scan/examples/standard/app.xcodeproj", device: "iPhone 5 (8.4)" }337 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)338 result = @test_command_generator.generate339 # FIXME: expect UI error starting "No simulators found that are equal to the version of specifier"340 end341 describe "test-without-building and build-for-testing" do342 before do343 options = { project: "./scan/examples/standard/app.xcodeproj", destination: [344 "platform=iOS Simulator,name=iPhone 6s,OS=9.3",345 "platform=iOS Simulator,name=iPad Air 2,OS=9.2"346 ] }347 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)348 end349 it "should build-for-testing", requires_xcodebuild: true do350 Scan.config[:build_for_testing] = true351 result = @test_command_generator.generate352 expect(result).to start_with([353 "set -o pipefail &&",354 "env NSUnbufferedIO=YES xcodebuild",355 "-scheme app",356 "-project ./scan/examples/standard/app.xcodeproj",357 "-destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' " \358 "-destination 'platform=iOS Simulator,name=iPad Air 2,OS=9.2'",359 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",360 "build-for-testing"361 ])362 end363 it "should test-without-building", requires_xcodebuild: true do364 Scan.config[:test_without_building] = true365 result = @test_command_generator.generate366 expect(result).to start_with([367 "set -o pipefail &&",368 "env NSUnbufferedIO=YES xcodebuild",369 "-scheme app",370 "-project ./scan/examples/standard/app.xcodeproj",371 "-destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' " \372 "-destination 'platform=iOS Simulator,name=iPad Air 2,OS=9.2'",373 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",374 "test-without-building"375 ])376 end377 it "should raise an exception if two build_modes are set", requires_xcodebuild: true do378 allow(FastlaneCore::FastlaneFolder).to receive(:path).and_return(".")379 expect do380 Fastlane::FastFile.new.parse("lane :test do381 scan(382 project: './scan/examples/standard/app.xcodeproj',383 test_without_building: true,384 build_for_testing: true385 )386 end").runner.execute(:test)387 end.to raise_error("Unresolved conflict between options: 'test_without_building' and 'build_for_testing'")388 end389 it "should run tests from xctestrun file", requires_xcodebuild: true do390 Scan.config[:xctestrun] = "/folder/mytests.xctestrun"391 result = @test_command_generator.generate392 expect(result).to start_with([393 "set -o pipefail &&",394 "env NSUnbufferedIO=YES xcodebuild",395 "-destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' " \396 "-destination 'platform=iOS Simulator,name=iPad Air 2,OS=9.2'",397 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",398 "-xctestrun '/folder/mytests.xctestrun'",399 "test-without-building"400 ])401 end402 end403 describe "Multiple devices example" do404 it "uses multiple destinations", requires_xcodebuild: true do405 options = { project: "./scan/examples/standard/app.xcodeproj", destination: [406 "platform=iOS Simulator,name=iPhone 6s,OS=9.3",407 "platform=iOS Simulator,name=iPad Air 2,OS=9.2"408 ] }409 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)410 result = @test_command_generator.generate411 expect(result).to start_with([412 "set -o pipefail &&",413 "env NSUnbufferedIO=YES xcodebuild",414 "-scheme app",415 "-project ./scan/examples/standard/app.xcodeproj",416 "-destination 'platform=iOS Simulator,name=iPhone 6s,OS=9.3' " \417 "-destination 'platform=iOS Simulator,name=iPad Air 2,OS=9.2'",418 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",419 :build,420 :test421 ])422 end423 it "uses multiple devices", requires_xcodebuild: true do424 options = { project: "./scan/examples/standard/app.xcodeproj", devices: [425 "iPhone 6s (9.3)",426 "iPad Air (9.3)"427 ] }428 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)429 result = @test_command_generator.generate430 expect(result).to start_with([431 "set -o pipefail &&",432 "env NSUnbufferedIO=YES xcodebuild",433 "-scheme app",434 "-project ./scan/examples/standard/app.xcodeproj",435 "-destination 'platform=iOS Simulator,id=70E1E92F-A292-4980-BC3C-7770C5EEFCFD' " \436 "-destination 'platform=iOS Simulator,id=DD134998-177F-47DA-99FA-D549D9305476'",437 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",438 :build,439 :test440 ])441 end442 it "de-duplicates devices matching same simulator", requires_xcodebuild: true do443 options = { project: "./scan/examples/standard/app.xcodeproj", devices: [444 "iPhone 5 (9.0)",445 "iPhone 5 (9.0.0)"446 ] }447 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)448 result = @test_command_generator.generate449 expect(result).to start_with([450 "set -o pipefail &&",451 "env NSUnbufferedIO=YES xcodebuild",452 "-scheme app",453 "-project ./scan/examples/standard/app.xcodeproj",454 "-destination 'platform=iOS Simulator,id=9905A018-9DC9-4DD8-BA14-B0B000CC8622'",455 "-derivedDataPath '#{Scan.config[:derived_data_path]}'",456 :build,457 :test458 ])459 end460 it "raises an error if multiple devices are specified for `device`" do461 expect do462 options = { project: "./scan/examples/standard/app.xcodeproj", device: [463 "iPhone 6s (9.3)",464 "iPad Air (9.3)"465 ] }466 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)467 end.to raise_error("'device' value must be a String! Found Array instead.")468 end469 it "raises an error if both `device` and `devices` were given" do470 expect do471 options = {472 project: "./scan/examples/standard/app.xcodeproj",473 device: ["iPhone 6s (9.3)"],474 devices: ["iPhone 6"]475 }476 Scan.config = FastlaneCore::Configuration.create(Scan::Options.available_options, options)477 end.to raise_error("'device' value must be a String! Found Array instead.")478 end479 end480 end481end...

Full Screen

Full Screen

connection_handling_test.rb

Source:connection_handling_test.rb Github

copy

Full Screen

...69 assert_equal 1, quit70 assert !redis.connected?71 end72 end73 def test_shutdown74 commands = {75 :shutdown => lambda { :exit }76 }77 redis_mock(commands) do |redis|78 # SHUTDOWN does not reply: test that it does not raise here.79 assert_equal nil, redis.shutdown80 end81 end82 def test_shutdown_with_error83 connections = 084 commands = {85 :select => lambda { |*_| connections += 1; "+OK\r\n" },86 :connections => lambda { ":#{connections}\r\n" },87 :shutdown => lambda { "-ERR could not shutdown\r\n" }88 }89 redis_mock(commands) do |redis|90 connections = redis.connections91 # SHUTDOWN replies with an error: test that it gets raised92 assert_raise Redis::CommandError do93 redis.shutdown94 end95 # The connection should remain in tact96 assert_equal connections, redis.connections97 end98 end99 def test_shutdown_from_pipeline100 commands = {101 :shutdown => lambda { :exit }102 }103 redis_mock(commands) do |redis|104 result = redis.pipelined do105 redis.shutdown106 end107 assert_equal nil, result108 assert !redis._client.connected?109 end110 end111 def test_shutdown_with_error_from_pipeline112 connections = 0113 commands = {114 :select => lambda { |*_| connections += 1; "+OK\r\n" },115 :connections => lambda { ":#{connections}\r\n" },116 :shutdown => lambda { "-ERR could not shutdown\r\n" }117 }118 redis_mock(commands) do |redis|119 connections = redis.connections120 # SHUTDOWN replies with an error: test that it gets raised121 assert_raise Redis::CommandError do122 redis.pipelined do123 redis.shutdown124 end125 end126 # The connection should remain in tact127 assert_equal connections, redis.connections128 end129 end130 def test_shutdown_from_multi_exec131 commands = {132 :multi => lambda { "+OK\r\n" },133 :shutdown => lambda { "+QUEUED\r\n" },134 :exec => lambda { :exit }135 }136 redis_mock(commands) do |redis|137 result = redis.multi do138 redis.shutdown139 end140 assert_equal nil, result141 assert !redis._client.connected?142 end143 end144 def test_shutdown_with_error_from_multi_exec145 connections = 0146 commands = {147 :select => lambda { |*_| connections += 1; "+OK\r\n" },148 :connections => lambda { ":#{connections}\r\n" },149 :multi => lambda { "+OK\r\n" },150 :shutdown => lambda { "+QUEUED\r\n" },151 :exec => lambda { "*1\r\n-ERR could not shutdown\r\n" }152 }153 redis_mock(commands) do |redis|154 connections = redis.connections155 # SHUTDOWN replies with an error: test that it gets returned156 # We should test for Redis::CommandError here, but hiredis doesn't yet do157 # custom error classes.158 err = nil159 begin160 redis.multi { redis.shutdown }161 rescue => err162 end163 assert err.kind_of?(StandardError)164 # The connection should remain intact165 assert_equal connections, redis.connections166 end167 end168 def test_slaveof169 redis_mock(:slaveof => lambda { |host, port| "+SLAVEOF #{host} #{port}" }) do |redis|170 assert_equal "SLAVEOF somehost 6381", redis.slaveof("somehost", 6381)171 end172 end173 def test_bgrewriteaof174 redis_mock(:bgrewriteaof => lambda { "+BGREWRITEAOF" }) do |redis|...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Minitest_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful