lib/lopata/runner.rb in lopata-0.1.28 vs lib/lopata/runner.rb in lopata-0.1.29

- old
+ new

@@ -7,20 +7,23 @@ require_relative 'condition' module Lopata # @private class Runner < Thor + class_option :env, default: :qa, aliases: 'e' + class_option :keep, type: :boolean, aliases: 'k' + desc 'test', 'Run tests' - option :env, default: :qa, aliases: 'e' option :rerun, type: :boolean, aliases: 'r' - option :keep, type: :boolean, aliases: 'k' option :text, aliases: 't' option :list, type: :boolean, aliases: 'l' option :init, type: :boolean, aliases: 'i' def test(*args) trap_interrupt configure_from_options + add_text_filter(options[:text]) if options[:text] + add_rerun_filter if options[:rerun] Lopata::Loader.load_shared_steps Lopata::Loader.load_scenarios(*args) if options[:list] list_scenarios elsif options[:init] @@ -28,13 +31,36 @@ else run_scenarios end end + desc 'suspect', 'Run suspect and not started tests' + option :skip, type: :numeric, default: 0, aliases: 's' + option :count, type: :numeric, default: 10, aliases: 'c' + def suspect(*args) + trap_interrupt + configure_from_options + Lopata::Loader.load_shared_steps + Lopata::Loader.load_scenarios(*args) + count = options[:count] + skip = options[:skip] + loop do + need_run = Lopata::Client.new.need_run + need_run = need_run[skip, count] + break if need_run.nil? + world = Lopata::World.new + world.scenarios.concat(Lopata.world.scenarios.select { |s| need_run.include?(s.title) }) + break if world.scenarios.empty? + world.notify_observers(:started, world) + world.scenarios.each { |s| s.run } + world.notify_observers(:finished, world) + end + end + default_task :test - register Generators::App, :new, 'lopata new project-name', 'Init new lopata projects' + register Generators::App, :new, 'new [project-name]', 'Init new lopata projects' def self.exit_on_failure? true end @@ -44,11 +70,9 @@ c.env = options[:env].to_sym c.keep = options[:keep] c.load_environment c.run_before_start_hooks end - add_text_filter(options[:text]) if options[:text] - add_rerun_filter if options[:rerun] end def add_text_filter(text) Lopata.configuration.filters << -> (scenario) { scenario.title.include?(text) } end