Class: Cucumber::Formatter::Failures

Inherits:
Object
  • Object
show all
Includes:
Console, Io
Defined in:
lib/cucumber/formatter/failures.rb

Overview

Failure formatter Will only output information when a test fails The output structure is:

Feature title

Scenario title
  Step text
    Full stacktrace

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runtime, path_or_io, options) ⇒ Failures

Returns a new instance of Failures.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cucumber/formatter/failures.rb', line 21

def initialize(runtime, path_or_io, options)
  @runtime = runtime
  @io = ensure_io(path_or_io)
  @options = options
  @exceptions = []
  @indent = 0
  @prefixes = options[:prefixes] || {}
  @delayed_messages = []
  @previous_step_keyword = nil
  @snippets_input = []
  @output = []
end

Instance Attribute Details

#indent=(value) ⇒ Object (writeonly)

Sets the attribute indent

Parameters:

  • value

    the value to set the attribute indent to.



18
19
20
# File 'lib/cucumber/formatter/failures.rb', line 18

def indent=(value)
  @indent = value
end

#runtimeObject (readonly)

Returns the value of attribute runtime.



19
20
21
# File 'lib/cucumber/formatter/failures.rb', line 19

def runtime
  @runtime
end

Instance Method Details

#after_background(_background) ⇒ Object



57
58
59
# File 'lib/cucumber/formatter/failures.rb', line 57

def after_background(_background)
  @in_background = false
end

#after_features(features) ⇒ Object



40
41
42
# File 'lib/cucumber/formatter/failures.rb', line 40

def after_features(features)
  print_summary(features)
end

#after_table_row(table_row) ⇒ Object



85
86
87
88
89
# File 'lib/cucumber/formatter/failures.rb', line 85

def after_table_row(table_row)
  return unless table_row.exception
  @table_row = "    Row: #{table_row.name}"
  exception(table_row.exception, table_row.status, 6)
end

#after_test_step(test_step, result) ⇒ Object



91
92
93
# File 'lib/cucumber/formatter/failures.rb', line 91

def after_test_step(test_step, result)
  collect_snippet_data(test_step, result)
end

#background_name(keyword, name, *_args) ⇒ Object



61
62
63
64
# File 'lib/cucumber/formatter/failures.rb', line 61

def background_name(keyword, name, *_args)
  simple_name = name.split("\n").first
  @background = "  #{keyword}: #{simple_name}"
end

#before_background(_background) ⇒ Object



53
54
55
# File 'lib/cucumber/formatter/failures.rb', line 53

def before_background(_background)
  @in_background = true
end

#before_feature(_feature) ⇒ Object



44
45
46
# File 'lib/cucumber/formatter/failures.rb', line 44

def before_feature(_feature)
  @background_failure = false
end

#before_features(_features) ⇒ Object



34
35
36
37
38
# File 'lib/cucumber/formatter/failures.rb', line 34

def before_features(_features)
  print_profile_information
  @io.puts 'Testing has started...'
  @io.flush
end

#exception(exception, status, indent = 6) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/cucumber/formatter/failures.rb', line 75

def exception(exception, status, indent = 6)
  unless @background_failure
    print_scenario_summary
    print_exception(exception, status, indent)
    @io.puts
    @io.flush
  end
  @background_failure = @in_background
end

#feature_name(keyword, name) ⇒ Object



48
49
50
51
# File 'lib/cucumber/formatter/failures.rb', line 48

def feature_name(keyword, name)
  simple_name = name.split("\n").first
  @feature = "#{keyword}: #{simple_name}"
end

#scenario_name(keyword, name, *_args) ⇒ Object



66
67
68
69
# File 'lib/cucumber/formatter/failures.rb', line 66

def scenario_name(keyword, name, *_args)
  simple_name = name.split("\n").first
  @scenario = "  #{keyword}: #{simple_name}"
end

#step_name(keyword, step_match, *_args) ⇒ Object



71
72
73
# File 'lib/cucumber/formatter/failures.rb', line 71

def step_name(keyword, step_match, *_args)
  @step = "    #{keyword}#{step_match.format_args}"
end