mardi 3 mars 2015

Run Rspec immediately again after failures

I'm doing some automated cross-browser testing with browserstack, and have a feature test running through a rake task for multiple browsers like so:



namespace :spec do
desc "Run Selenium and record results to BrowserStack"
task :browser_testing_demo => [:environment] do
BROWSERS.keys.each do |browser_name|
puts "Cross browser testing against #{browser_name}."

Rake::Task["browser_testing_demo:#{browser_name}"].execute
end
end
end

namespace :browser_testing_demo do
BROWSERS.keys.each do |browser_key|
RSpec::Core::RakeTask.new("#{browser_key}_run".to_sym) do |t|
t.pattern = 'spec/cross_browser/cross_browser_ui_spec.rb'
end

desc "Run rspec against #{BROWSERS[browser_key]['browser']} #{BROWSERS[browser_key]['browser_version']}"
task browser_key do
ENV['BROWSER_TASK_NAME'] = browser_key

Rake::Task["browser_testing_demo:#{browser_key}_run"].execute
end
end
end


BROWSERS is just an imported json file with different browser configurations I'm interested in. This works perfectly (connects with browserstack, runs tests, and records screenshots for all browsers) providing there are no errors. The issue is when a failure or other error happens. This causes the rspec to dump the results ("Failed exaples: ...") and the next rake task doesn't commence. Any way to stop this behavior from happening?


(i've tried rescue blocks in various places to no avail. I'm thinking there may be an rspec config that i can set?)


Aucun commentaire:

Enregistrer un commentaire