Sha256: 9e3341b2295e18d9e947c12c51a4d69c02b13ea42637b2f110d22588bfd5736c

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

class Case
  # READ: sessions, config, groups, action, report
  # TODO: groups from Project or from Case???
  def play
    if skip?
      verbose Rainbow("S").green
      return false
    end
    start_time = Time.now
    play_groups_in_sequence
    fill_report(start_time, Time.now)
    close_opened_sessions
  end
  alias_method :start, :play

  private

  def close_opened_sessions
    @sessions.each_value do |s|
      s.close if s.instance_of? Net::SSH::Connection::Session
    end
  end

  def play_groups_in_sequence
    verboseln "\n=> Starting case [#{@config.get(:tt_members)}]" if get(:tt_sequence) == true
    @groups.each do |t|
      @action[:groupname] = t[:name]
      instance_eval(&t[:block])
    end
  end

  def play_groups_in_parallel
    verboseln "Starting case [#{@config.get(:tt_members)}]"
    @groups.each do |t|
      verbose "* Processing [#{t[:name]}] "
      @action[:groupname] = t[:name]
      instance_eval(&t[:block])
      verbose "\n"
    end
    verboseln "\n"
  end

  def fill_report(start_time, finish_time)
    @report.head.merge! @config.global
    @report.head.merge! @config.local
    @report.head.merge! @config.running
    @report.tail[:case_id] = @id
    @report.tail[:start_time] = start_time
    @report.tail[:finish_time] = finish_time
    @report.tail[:duration] = finish_time - start_time
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
teuton-2.9.2 lib/teuton/case/play.rb
teuton-2.9.1 lib/teuton/case/play.rb
teuton-2.9.0 lib/teuton/case/play.rb