mercredi 11 avril 2018

retry failed tests in rspec

I'm having a nearly identical issue as listed ( Why is Rake not able to invoke multiple tasks consecutively? ) but their solutions aren't working for me! As my codebase has grown, I periodically get false-negatives, and I would love to rerun only failed tests. The below exits out on completion of line Rake::Task['test:example_1'].execute ( and wont hit a byebyg / binding.pry ) on the next line down.

SPEC_PATH = 'spec/platform/**/*.rb'

namespace :test do

RSpec::Core::RakeTask.new('example_1') do |t|
  t.rspec_opts = ["-Ilib","--format documentation","--color --tty"]
  t.pattern = SPEC_PATH
end

RSpec::Core::RakeTask.new('example_2') do |t|
  t.rspec_opts = ["-Ilib","--format documentation","--color --tty", "--only-failures"]
  t.pattern = SPEC_PATH
end

desc 'Run "test" task, then rerun failed tests'
  RSpec::Core::RakeTask.new('rerun') do |t|
    2.times do
      Rake::Task['test:example_1'].execute
      Rake::Task['test:example_2'].execute
    end
  end
end

Including --dry-run to test:example_1 will run both, but obviously, no failures are generated, so it isn't helpful. Is there a config I need to set to prevent exit upon completion? I haven't been able to find it if so.

Thanks.

Aucun commentaire:

Enregistrer un commentaire