Module: QAT::Formatter::Helper

Includes:
Builder, UtilityFuction
Included in:
Console, Dashboard, Scenario::Name, Tags, TestIds
Defined in:
lib/qat/formatter/helper.rb

Overview

Helper for Formatters , most of the main methods are done to reduce code duplication

Since:

  • 0.1.0

Instance Method Summary collapse

Methods included from UtilityFuction

#background, #calculate_row_number, #create_feature_hash, #features?, #get_example_values, #get_lines_from_scenario

Methods included from Builder

#add_values_to_examples, #build, #create_id_from_scenario_source, #feature, #get_scenario_tags, #scenario

Instance Method Details

#assign_print_featureObject

Since:

  • 0.1.0



61
62
63
64
65
66
# File 'lib/qat/formatter/helper.rb', line 61

def assign_print_feature
  @current_feature = @feature_hash
  feature_name     = @current_feature[:name]
  print_scenario_start @current_feature[:keyword], feature_name
  mdc_before_feature! feature_name
end

#on_test_case_finished(event) ⇒ Object

Since:

  • 0.1.0



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/qat/formatter/helper.rb', line 26

def on_test_case_finished event
  return if @config.dry_run?
  _test_case, result = *event.attributes
  @current_feature   = nil
  if result.failed?
    mdc_add_step! @mdc_text
    mdc_add_status_failed!
    log.error { result.exception }
  else
    print_scenario_results @current_scenario[:keyword], @current_scenario[:name], result
  end
end

#on_test_case_started(event) ⇒ Object

Since:

  • 0.1.0



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/qat/formatter/helper.rb', line 13

def on_test_case_started event
  return if @config.dry_run?
  @row_number = nil
  test_case   = event.test_case
  build(test_case, @ast_lookup)
  assign_print_feature unless @current_feature
  @current_scenario = @scenario
  scenario_name     = @current_scenario[:name]
  print_scenario_start @current_scenario[:keyword], scenario_name
  mdc_before_scenario! scenario_name, @current_scenario[:tags], @row_number, @examples_values
end

#on_test_run_finished(_event) ⇒ Object

Since:

  • 0.1.0



55
56
57
58
59
# File 'lib/qat/formatter/helper.rb', line 55

def on_test_run_finished _event
  return if @config.dry_run?
  print_scenario_results @feature_hash[:keyword], @feature_hash[:name]
  mdc_after_feature!
end

#on_test_step_finished(event) ⇒ Object

Since:

  • 0.1.0



48
49
50
51
52
53
# File 'lib/qat/formatter/helper.rb', line 48

def on_test_step_finished(event)
  return if @config.dry_run?
  test_step, result = *event.attributes
  return unless features?(test_step)
  log.info "Step Done!"
end

#on_test_step_started(event) ⇒ Object

Since:

  • 0.1.0



39
40
41
42
43
44
45
# File 'lib/qat/formatter/helper.rb', line 39

def on_test_step_started(event)
  return if @config.dry_run?
  test_step = event.test_step
  return unless features?(test_step)
  step_source = @ast_lookup.step_source(test_step).step
  print_assign_step test_step, step_source
end

Since:

  • 0.1.0



69
70
71
72
73
74
# File 'lib/qat/formatter/helper.rb', line 69

def print_assign_step test_step, step_source
  test_step_text = test_step.text
  log.info { "Step \"#{test_step_text}\"" }
  @mdc_text = "#{step_source.keyword}#{test_step_text}"
  mdc_add_step! @mdc_text
end

Since:

  • 0.1.0



76
77
78
79
80
81
82
# File 'lib/qat/formatter/helper.rb', line 76

def print_scenario_results keyword, name, result = nil
  if result
    log.info { "Finished #{keyword}: \"#{name}\" - #{result}\n" }
  else
    log.info { "Finished #{keyword}: \"#{name}\"" }
  end
end

Since:

  • 0.1.0



84
85
86
# File 'lib/qat/formatter/helper.rb', line 84

def print_scenario_start keyword, name
  log.info { "Running #{keyword}: \"#{name}\"" }
end