Class: Quke::ParallelConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/quke/parallel_configuration.rb

Overview

Manages all parallel configuration for Quke.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ParallelConfiguration

Returns a new instance of ParallelConfiguration.



18
19
20
21
22
23
24
# File 'lib/quke/parallel_configuration.rb', line 18

def initialize(config)
  @config = config
  data = @config.data["parallel"] || {}
  @enabled = (data["enable"].to_s.downcase.strip == "true")
  @group_by = (data["group_by"] || "default").downcase.strip
  @processes = (data["processes"] || "0").to_s.downcase.strip.to_i
end

Instance Attribute Details

#enabledObject (readonly)

Whether use of parallel tests has been enabled



11
12
13
# File 'lib/quke/parallel_configuration.rb', line 11

def enabled
  @enabled
end

#group_byObject (readonly)

How to group the tests. Default is features



13
14
15
# File 'lib/quke/parallel_configuration.rb', line 13

def group_by
  @group_by
end

#processesObject (readonly)

How many processes to start. Default is 0 which means we will leave ParallelTests to determine the number.



16
17
18
# File 'lib/quke/parallel_configuration.rb', line 16

def processes
  @processes
end

Instance Method Details

#command_args(additional_args = []) ⇒ Object

Returns an array of arguments, correctly ordered for passing to ParallelTests::CLI.new.run().

The arguments are based on the values set for the parallel configuration plus those passed in. It then orders them in an order that makes sense to parallel tests.



32
33
34
35
36
37
38
# File 'lib/quke/parallel_configuration.rb', line 32

def command_args(additional_args = [])
  args = standard_args(@config.features_folder)
  args += ["--single", "--quiet"] unless @enabled
  args += ["--group-by", @group_by] unless @group_by == "default"
  args += ["-n", @processes.to_s] if @enabled && @processes.positive?
  args + ["--test-options", @config.cucumber_arg(additional_args)]
end