Class: Cucumber::Distrib::Configuration

Inherits:
Object
  • Object
show all
Includes:
DistribCore::Configuration
Defined in:
lib/cucumber/distrib/configuration.rb

Overview

Configuration holder.

Examples:

Get global instance of configuration:

Cucumber::Distrib.configuration

Override default list of the tests:

Cucumber::Distrib.configure do |config|
  config.tests_provider = -> {
    Dir.glob(['features/**/*.feature', 'engines/**/*.feature'])
  }
end

Specify which errors should fail leader. Other errors will be retried, here you can specify how many times.

RSpec::Distrib.configure do |config|
  config.error_handler.retryable_exceptions = ['Elasticsearch::ServiceUnavailable']
  config.error_handler.retry_attempts = 2
  config.error_handler.fatal_worker_failures = ['NameError']
  config.error_handler.failed_workers_threshold = 2
end

Or set your own logic to handle errors. It should respond to ‘#retry_test?`, `#ignore_worker_failure?` methods.

RSpec::Distrib.configure do |config|
  config.error_handler = MyErrorHandler
end

Set equal timeout for all tests to 30 seconds:

Cucumber::Distrib.configure do |config|
  config.test_timeout = 30 # seconds
end

Or you can specify timeout per test. An object that responds to ‘call` and receives the test as an argument. The proc returns the timeout in seconds.

Cucumber::Distrib.configure do |config|
  config.test_timeout = ->(test) do
    10 + 2 * average_execution_in_seconds(test)
  end
end

Set how long Leader will wait before first test gets processed by workers. Leader will exit if no tests picked in this period.

Cucumber::Distrib.configure do |config|
  config.first_test_picked_timeout = 10*60 # seconds
end

Specify custom options for DRb service. Defaults are ‘{ safe_level: 1 }`. @see `DRb::DRbServer.new` for complete list

Cucumber::Distrib.configure do |config|
  config.drb = {safe_level: 0, verbose: true}
end

Specify custom block to pre-process examples before reporting them to Leader. Useful to add additional information about workers.

Cucumber::Distrib.configure do |config|
  config.before_test_report = -> (file_name, example_groups) do
    example_groups.each { |eg| eg.[:custom] = 'foo' }
  end
end

Specify custom block which will be called on Leader after run.

Cucumber::Distrib.configure do |config|
  config.on_finish = -> () do
    'Whatever logic before Leader exit'
  end
end

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



71
72
73
74
75
76
77
# File 'lib/cucumber/distrib/configuration.rb', line 71

def initialize
  super
  @tests_provider = ::Cucumber::Distrib::Leader::TestsProvider
  @error_handler = ::DistribCore::Leader::ErrorHandler.new(
    ::Cucumber::Distrib::Leader::CucumberHelper
  )
end