Skip to content

Instantly share code, notes, and snippets.

@joelbyler
Created December 6, 2012 15:57
Show Gist options
  • Save joelbyler/4225565 to your computer and use it in GitHub Desktop.
Save joelbyler/4225565 to your computer and use it in GitHub Desktop.
Cucumber Rerun Rake Task
require 'cucumber/rake/task'
def run_rake_task(name)
begin
Rake::Task[name].invoke
rescue Exception => e
return false
end
true
end
STDERR.puts ENV['PROFILE']
desc 'Run regression'
Cucumber::Rake::Task.new :regression do |t|
t.cucumber_opts = ["-p #{ENV['PROFILE']}", "--format rerun --out #{ENV['PROFILE']}_rerun.txt"]
end
desc 'Rerun failed tests'
Cucumber::Rake::Task.new :rerun do |t|
t.cucumber_opts = ["-p #{ENV['PROFILE']}", "@#{ENV['PROFILE']}_rerun.txt"]
end
desc 'Run regression and rerun failed tests'
task :regression_with_retry do
first_successful = run_rake_task("regression")
rerun_successful = true
unless first_successful
rerun_successful = run_rake_task("rerun")
end
unless first_successful || rerun_successful
raise 'Cucumber tests failed'
end
end
#jruby -S rake regression_with_retry PROFILE=regression_a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment