Permalink
Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign up
Fetching contributors…
Cannot retrieve contributors at this time.
Cannot retrieve contributors at this time
| require 'rspec/core/rake_task' | |
| require 'parallel_cucumber' | |
| # | |
| # DEFAULT VALUES | |
| # | |
| @success = true | |
| ENV['TEST_RUNNER'] = 'rspec' | |
| # | |
| # Cucumber and RSpec can not be run at the same time | |
| # The default task uses the runner based on the setting of ENV['TEST_RUNNER'] | |
| # | |
| task :default do | |
| Rake::MultiTask[:test_all].invoke | |
| end | |
| desc "Run All Tests with RSpec" | |
| task :test_rspec do | |
| ENV['BUILD_TAG'] += "-#{ENV['TEST_RUNNER']}" if ENV['BUILD_TAG'] | |
| Rake::MultiTask[:test_all].invoke | |
| end | |
| desc "Run All Tests with Cucumber" | |
| task :test_cucumber do | |
| ENV['TEST_RUNNER'] = 'cucumber' | |
| ENV['BUILD_TAG'] += "-#{ENV['TEST_RUNNER']}" if ENV['BUILD_TAG'] | |
| Rake::MultiTask[:test_all].invoke | |
| end | |
| # | |
| # DESKTOP TASKS | |
| # | |
| desc "Run All Desktop Tests" | |
| multitask :test_desktop => [ | |
| :windows_10_edge_14, | |
| :windows_10_firefox_49, | |
| :windows_7_ie_11, | |
| :os_x_10_11_safari_10, | |
| :os_x_10_10_chrome_54 | |
| ] do | |
| raise StandardError, "Tests failed!" unless @success | |
| end | |
| desc "Run Tests on Windows 10 using Edge 14" | |
| task :windows_10_edge_14 do | |
| ENV['SPEC_TYPE'] = 'desktop' | |
| ENV['platform'] = 'Windows 10' | |
| ENV['browserName'] = 'MicrosoftEdge' | |
| ENV['version'] = '14.14393' | |
| ENV['JUNIT_DIR'] = 'junit_reports/windows_10_edge_14' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| desc "Run Tests on Windows 10 using Firefox 49" | |
| task :windows_10_firefox_49 do | |
| ENV['SPEC_TYPE'] = 'desktop' | |
| ENV['platform'] = 'Windows 10' | |
| ENV['browserName'] = 'firefox' | |
| ENV['version'] = '49.0' | |
| ENV['JUNIT_DIR'] = 'junit_reports/windows_10_firefox_49' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| desc "Run Tests on Windows 7 using IE 11" | |
| task :windows_7_ie_11 do | |
| ENV['SPEC_TYPE'] = 'desktop' | |
| ENV['platform'] = 'Windows 7' | |
| ENV['browserName'] = 'internet Explorer' | |
| ENV['version'] = '11.0' | |
| ENV['JUNIT_DIR'] = 'junit_reports/windows_7_ie_11' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| desc "Run Tests on OSX 10.10 using Safari 10" | |
| task :os_x_10_11_safari_10 do | |
| ENV['SPEC_TYPE'] = 'desktop' | |
| ENV['platform'] = 'OS X 10.11' | |
| ENV['browserName'] = 'safari' | |
| ENV['version'] = '10.0' | |
| ENV['JUNIT_DIR'] = 'junit_reports/os_x_10_11_safari_10' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| desc "Run Tests on OSX 10.11 using Chrome 54" | |
| task :os_x_10_10_chrome_54 do | |
| ENV['SPEC_TYPE'] = 'desktop' | |
| ENV['platform'] = 'OS X 10.10' | |
| ENV['browserName'] = 'chrome' | |
| ENV['version'] = '54.0' | |
| ENV['JUNIT_DIR'] = 'junit_reports/os_x_10_10_chrome_54' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| # | |
| # IOS SIMULATOR TASKS | |
| # | |
| desc "Run All IOS Simulator Tests" | |
| multitask :test_ios_simulators => [ | |
| :iPad_Air_2_Simulator, | |
| :iPhone_7_Simulator | |
| ] do | |
| raise StandardError, "Tests failed!" unless @success | |
| end | |
| desc "Run Tests on iPad Air 2 Simulator" | |
| task :iPad_Air_2_Simulator do | |
| ENV['SPEC_TYPE'] = 'ios' | |
| ENV['app'] = 'https://github.com/saucelabs-sample-test-frameworks/GuineaPig-Sample-App/blob/master/iOS/simulator/SauceGuineaPig-sim-debug.app.zip?raw=true' | |
| ENV['deviceName'] = 'iPad Air 2 Simulator' | |
| ENV['platformVersion'] = '9.3' | |
| ENV['appiumVersion'] = '1.6.3' | |
| ENV['platformName'] = 'ios' | |
| ENV['deviceOrientation'] = 'portrait' | |
| ENV['browserName'] = '' | |
| ENV['JUNIT_DIR'] = 'junit_reports/iPad_Air_2_Simulator' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| desc "Run Tests on iPhone 7 Simulator" | |
| task :iPhone_7_Simulator do | |
| ENV['SPEC_TYPE'] = 'ios' | |
| ENV['app'] = 'https://github.com/saucelabs-sample-test-frameworks/GuineaPig-Sample-App/blob/master/iOS/simulator/SauceGuineaPig-sim-debug.app.zip?raw=true' | |
| ENV['deviceName'] = 'iPhone 7 Simulator' | |
| ENV['platformVersion'] = '10.0' | |
| ENV['appiumVersion'] = '1.6.3' | |
| ENV['platformName'] = 'ios' | |
| ENV['deviceOrientation'] = 'portrait' | |
| ENV['browserName'] = '' | |
| ENV['JUNIT_DIR'] = 'junit_reports/iPhone_7_Simulator' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| # | |
| # ANDROID EMULATOR TASKS | |
| # | |
| desc "Run All IOS Simulator Tests" | |
| multitask :test_android_emulators => [ | |
| :test_android_emulator_5, | |
| :test_android_s4_4_4 | |
| ] do | |
| raise StandardError, "Tests failed!" unless @success | |
| end | |
| desc "Run Tests on Android 5 Emulator" | |
| task :test_android_emulator_5 do | |
| ENV['SPEC_TYPE'] = 'android' | |
| ENV['appiumVersion'] = '1.5.3' | |
| ENV['deviceOrientation'] = 'portrait' | |
| ENV['platformName'] = 'Android' | |
| ENV['app'] = 'https://github.com/saucelabs-sample-test-frameworks/GuineaPig-Sample-App/blob/master/android/GuineaPigApp-debug.apk?raw=true' | |
| ENV['deviceName'] = 'Android Emulator' | |
| ENV['platformVersion'] = '5.1' | |
| ENV['JUNIT_DIR'] = 'junit_reports/test_android_emulator_5' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| desc "Run Tests on Android S4 Emulator" | |
| task :test_android_s4_4_4 do | |
| ENV['SPEC_TYPE'] = 'android' | |
| ENV['appiumVersion'] = '1.5.3' | |
| ENV['deviceOrientation'] = 'portrait' | |
| ENV['platformName'] = 'Android' | |
| ENV['app'] = 'https://github.com/saucelabs-sample-test-frameworks/GuineaPig-Sample-App/blob/master/android/GuineaPigApp-debug.apk?raw=true' | |
| ENV['deviceName'] = 'Samsung Galaxy S4 Emulator' | |
| ENV['platformVersion'] = '4.4' | |
| ENV['browserName'] = '' | |
| ENV['JUNIT_DIR'] = 'junit_reports/test_android_s4_4_4' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| # | |
| # Real Device Tests | |
| # | |
| desc "Run Tests on Samsung S6 Device" | |
| task :test_android_device do | |
| ENV['SPEC_TYPE'] = 'android' | |
| ENV['deviceName'] = 'Samsung_Galaxy_S6_POC06' | |
| ENV['JUNIT_DIR'] = 'junit_reports/android_device' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| desc "Run Tests on iPhone 6 Device" | |
| task :test_ios_device do | |
| ENV['SPEC_TYPE'] = 'ios' | |
| ENV['deviceName'] = 'iPhone_6_Plus_16GB_real' | |
| ENV['JUNIT_DIR'] = 'junit_reports/ios_device' | |
| Rake::Task["run_#{ENV['TEST_RUNNER']}"].execute | |
| end | |
| # | |
| # HELPER Tasks, Don't run directly | |
| # | |
| # | |
| # Note - Can not run multiple real devices at the same time since each device | |
| # requires its own ENV['TESTOBJECT_API_KEY'] | |
| # | |
| multitask :test_all => [ | |
| :windows_10_edge_14, | |
| :windows_10_firefox_49, | |
| :windows_7_ie_11, | |
| :os_x_10_11_safari_10, | |
| :os_x_10_10_chrome_54, | |
| :iPad_Air_2_Simulator, | |
| :iPhone_7_Simulator, | |
| :test_android_emulator_5, | |
| :test_android_s4_4_4 | |
| ] do | |
| raise StandardError, "Tests failed!" unless @success | |
| end | |
| task :run_rspec do | |
| FileUtils.mkpath(ENV['JUNIT_DIR'][/^[^\/]+/]) | |
| begin | |
| @result = system "parallel_split_test spec/#{ENV['SPEC_TYPE']} --format d --out #{ENV['JUNIT_DIR']}.xml" | |
| ensure | |
| @success &= @result | |
| end | |
| end | |
| task :run_cucumber do | |
| FileUtils.mkpath(ENV['JUNIT_DIR']) | |
| begin | |
| @result = system "parallel_cucumber features -o \"--format junit --out #{ENV['JUNIT_DIR']} --format pretty\" -n 20" | |
| ensure | |
| @success &= @result | |
| end | |
| end |