Class: Launcuke::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/launcuke/runner.rb

Overview

Actual clas that will spawn one command process per directory of features collected according to configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(features_root) {|_self| ... } ⇒ Runner

Returns a new instance of Runner.

Yields:

  • (_self)

Yield Parameters:



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/launcuke/runner.rb', line 102

def initialize(features_root)
  @features_root_path = features_root
  yield self if block_given?
  @extra_options ||= []
  @mode = @extra_options[2]? "#{@extra_options[2]}" : 'sequential'
  @extra_options.delete_at(2)
  @dry_run = false if dry_run.nil?
  @forks_pool_size ||= 5
  @require_features_root_option = true if require_features_root_option.nil?
  @output_dir_name = "#{@extra_options[1]}" unless output_dir_name
  @output_path = File.expand_path("../reports", output_dir_name) unless output_path
  @excluded_dirs ||= []
  @included_only_dirs ||= []
  @launch_time = Time.now.strftime('%Y-%m-%d %H:%M:%S')
  @reports_path = File.join(output_path, output_dir_name)
  @system_command ||= SystemCommand.new
end

Instance Attribute Details

#dry_runObject

Optional. If true will generate index file but not launch processes. Used for testing.



88
89
90
# File 'lib/launcuke/runner.rb', line 88

def dry_run
  @dry_run
end

#excluded_dirsObject

Optional regexp for name of features directories to exclude.



73
74
75
# File 'lib/launcuke/runner.rb', line 73

def excluded_dirs
  @excluded_dirs
end

#extra_optionsObject

Array of extra options to pass to the command. Ex: [“-p”, “my_profile”, “–backtrace”]



79
80
81
# File 'lib/launcuke/runner.rb', line 79

def extra_options
  @extra_options
end

#features_root_pathObject

Root path to your features directory. Ex: your_project/features



64
65
66
# File 'lib/launcuke/runner.rb', line 64

def features_root_path
  @features_root_path
end

#forks_pool_sizeObject

Define the size for the pool of forks. Default is 5



82
83
84
# File 'lib/launcuke/runner.rb', line 82

def forks_pool_size
  @forks_pool_size
end

#included_only_dirsObject

Optional only the features directories to be included



76
77
78
# File 'lib/launcuke/runner.rb', line 76

def included_only_dirs
  @included_only_dirs
end

#launch_timeObject

Define last launch time, display in index.html



100
101
102
# File 'lib/launcuke/runner.rb', line 100

def launch_time
  @launch_time
end

#modeObject

Define the launch mode, parallel or sequential



97
98
99
# File 'lib/launcuke/runner.rb', line 97

def mode
  @mode
end

#output_dir_nameObject

Optional name for directory containing the reports. Default to ‘cucumber_reports’



67
68
69
# File 'lib/launcuke/runner.rb', line 67

def output_dir_name
  @output_dir_name
end

#output_pathObject

Optional full path for generated reports. Default to ../#features_root_path.



70
71
72
# File 'lib/launcuke/runner.rb', line 70

def output_path
  @output_path
end

#reports_pathObject (readonly)

Full final path where html reports will be generated



85
86
87
# File 'lib/launcuke/runner.rb', line 85

def reports_path
  @reports_path
end

#require_features_root_optionObject

Add cucumber –require option load *.rb files under features root path by default unless specified to false.



91
92
93
# File 'lib/launcuke/runner.rb', line 91

def require_features_root_option
  @require_features_root_option
end

#system_commandObject

Delegate to a wrapper of system call in order mock/test



94
95
96
# File 'lib/launcuke/runner.rb', line 94

def system_command
  @system_command
end

Instance Method Details

#startObject



120
121
122
123
124
125
126
127
# File 'lib/launcuke/runner.rb', line 120

def start
  FileUtils.mkdir_p reports_path
  exit_status = launch_process
  collect_results
  reports = ReportsIndex.new(reports_path, features_dirs, @launch_time).generate
  puts "See reports index at #{reports.index_path}" if reports
  system_command.exit(exit_status)
end