Class: Kymera::Cucumber::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/kymera/cucumber/cucumber_test_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, run_id, result_address = nil) ⇒ Runner

This is the test runner. It is responsible for the actual running of the test. It takes in 3 parameters. The first being options(Array). These are the options to be used for the cucumber test run. The run_id(String), this is a unique id identifying the test run that this test is for. It is used as the channel name for publishing results on the results bus. And lastly results_bus(SSocket), this is a socket object representing the results bus. This is what is used for publishing results to that bus



9
10
11
12
13
14
# File 'lib/kymera/cucumber/cucumber_test_runner.rb', line 9

def initialize(options, run_id, result_address = nil)
  @options = options
  @result_address = result_address
  @run_id = run_id
  ENV["AUTOTEST"] = "1" if $stdout.tty?
end

Instance Method Details

#run_test(test, branch, options = @options, run_id = @run_id) ⇒ Object

This is kicking off the test. Takes in 3 parameters, test(String) is the test to be executed. options(Array) is an array of the options to be used with this test run. By default, it uses the options passed in with the constructor. run_id(String) is the id of test run that this test is associated with. This is also defaulted with what was passed in with the constructor



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/kymera/cucumber/cucumber_test_runner.rb', line 19

def run_test(test, branch, options = @options, run_id = @run_id)
  result_bus = nil
  puts "Checking to see if a results bus address was passed in..."
  unless @result_address.nil?
    puts "A results bus address was passed in...generating socket..."
    result_bus = SZMQ.new.socket(@result_address, 'pub')
    puts "Connecting to bus..."
    result_bus.connect
  end

  _results = ''
  _options = ''
  options.each do |option|
    _options += " #{option}"
  end

  puts "Switching to specified branch..."
  # switch_to_branch(branch)

  puts "Running test: #{test}"
  io = Object::IO.popen("bundle exec cucumber #{test} #{_options}")
  until io.eof? do
    result = io.gets
    unless result_bus.nil?
      result_bus.publish_message(run_id, result)
    end
    _results += result
  end
  Process.wait2(io.pid)
  result_bus.close unless result_bus.nil?
  _results
end