Class: Cucumber::Distrib::Worker::CucumberRunner

Inherits:
Runtime
  • Object
show all
Includes:
DistribCore::Worker
Defined in:
lib/cucumber/distrib/worker/cucumber_runner.rb

Overview

Modified runner for Cucumber to consume and run tests from Leader.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(leader) ⇒ CucumberRunner

Connects to Leader and loads configuration using profiles received from Leader.

Parameters:

  • leader (DRbObject)

See Also:

  • Runtime#initialize


33
34
35
36
37
38
39
40
# File 'lib/cucumber/distrib/worker/cucumber_runner.rb', line 33

def initialize(leader)
  @leader = leader
  profiles = connect_to_leader_with_timeout { leader.profiles }

  handle_configuration_failure do
    super(prepare_configuration(profiles))
  end
end

Class Method Details

.run_from_leader(leader_ip) ⇒ Object

Public method that invokes the runner.

Parameters:

  • leader_ip (String)


23
24
25
26
# File 'lib/cucumber/distrib/worker/cucumber_runner.rb', line 23

def self.run_from_leader(leader_ip)
  leader = ::DRbObject.new_with_uri(Leader::DRB_SERVER_URL % leader_ip)
  new(leader).run!
end

Instance Method Details

#run!Object

Note:

Originally it loads all step definitions and executes all features. We change it behaviour to consume queue of Leader.

Loads definitions of steps and executes features from Leader.

See Also:

  • Runtime#run!


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/cucumber/distrib/worker/cucumber_runner.rb', line 48

def run! # rubocop:disable Metrics/MethodLength
  receiver = nil

  handle_configuration_failure do
    # This 5 lines below are the same as in the original code.
    load_step_definitions
    install_wire_plugin
    # Fire if defined.
    fire_after_configuration_hook if defined?(:fire_after_configuration_hook)
    fire_install_plugin_hook if defined?(:fire_install_plugin_hook)
    self.visitor = report
    receiver = Cucumber::Core::Test::Runner.new(@configuration.event_bus)
  end

  consume_queue(receiver)

  @configuration.notify :test_run_finished

  exit_code = determine_exit_code
  logger.info "Worker exiting with exit code #{exit_code}..."

  exit_code
end