Class: Sauce::Jasmine::Runner
- Inherits:
-
Object
- Object
- Sauce::Jasmine::Runner
- Defined in:
- lib/sauce/jasmine/runner.rb
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
- #run_tests ⇒ Object
- #run_tests_in_browser(os, browser, browser_version) ⇒ Object
- #setup ⇒ Object
- #teardown ⇒ Object
Constructor Details
Instance Method Details
#run ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/sauce/jasmine/runner.rb', line 9 def run setup begin run_tests ensure teardown end end |
#run_tests ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sauce/jasmine/runner.rb', line 29 def run_tests puts "running tests..." browsers = Sauce::Config.new.browsers results = {} threads = browsers.map do |browser_spec| browser_string = browser_spec.join('/') Thread.new do begin result, job_id = run_tests_in_browser(*browser_spec) puts "Suite finished on #{browser_string}" Thread.exclusive do results[browser_string] = result, job_id end rescue => e results[browser_string] = e end end end threads.each(&:join) results.each do |browser_string, result| if result.respond_to? :[] actual_result, job_id = result success = actual_result && actual_result.values.all? {|suite_result| suite_result['result'] == "passed"} if !success puts "[FAILURE] Failure on #{browser_string}. See https://saucelabs.com/jobs/#{job_id} for details." at_exit { exit!(1) } end else raise result end end end |
#run_tests_in_browser(os, browser, browser_version) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/sauce/jasmine/runner.rb', line 70 def run_tests_in_browser(os, browser, browser_version) driver = SeleniumDriver.new(os, browser, browser_version, @config.tunnel_domain) driver.connect job_id = driver.job_id begin while !driver.tests_have_finished? sleep 1.0 end result = driver.test_results ensure driver.disconnect return result, job_id end end |
#setup ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sauce/jasmine/runner.rb', line 18 def setup @server.start puts "Setting up Sauce Connect..." @tunnel = Sauce::Connect.new(:domain => @config.tunnel_domain, :host => @server.host, :port => @server.port, :quiet => @config.quiet_tunnel?) @tunnel.wait_until_ready puts "Sauce Connect ready" end |
#teardown ⇒ Object
64 65 66 67 68 |
# File 'lib/sauce/jasmine/runner.rb', line 64 def teardown puts "Shutting down Sauce Connect..." @tunnel.disconnect puts "Sauce Connect shut down" end |