Class: Gurke::Reporters::TeamCityReporter

Inherits:
NullReporter show all
Defined in:
lib/gurke/reporters/team_city_reporter.rb

Overview

The TeamCityReporter prints features, scenarios and steps in a format parseable by TeamCity CI.

Constant Summary

Constants inherited from Gurke::Reporter

Gurke::Reporter::CALLBACKS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Gurke::Reporter

#before_features, #end_feature, #end_features, #end_scenario, #end_step, #start_feature, #start_features, #start_scenario, #start_step

Constructor Details

#initialize(io = $stdout) ⇒ TeamCityReporter

Returns a new instance of TeamCityReporter.



8
9
10
# File 'lib/gurke/reporters/team_city_reporter.rb', line 8

def initialize(io = $stdout)
  @io = io
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



7
8
9
# File 'lib/gurke/reporters/team_city_reporter.rb', line 7

def io
  @io
end

Instance Method Details

#after_feature(feature) ⇒ Object



57
58
59
# File 'lib/gurke/reporters/team_city_reporter.rb', line 57

def after_feature(feature)
  publish :testSuiteFinished, name: feature.name
end

#after_features(features) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/gurke/reporters/team_city_reporter.rb', line 61

def after_features(features)
  scenarios = features.map(&:scenarios).flatten

  example_count = scenarios.size
  failure_count = scenarios.select(&:failed?).size
  pending_count = scenarios.select(&:pending?).size

  io.puts "  #{example_count} scenarios: " \
          "#{failure_count} failing, " \
          "#{pending_count} pending"
  io.puts
end

#after_scenario(scenario) ⇒ Object



53
54
55
# File 'lib/gurke/reporters/team_city_reporter.rb', line 53

def after_scenario(scenario)
  publish :testFinished, name: scenario.name
end

#after_step(step) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/gurke/reporters/team_city_reporter.rb', line 42

def after_step(step, *)
  case step.state
    when :pending then print_pending step
    when :failed  then print_failed step
    when :success then print_braces 'success'
    else print_braces 'skipped'
  end
  io.puts
  io.flush
end

#before_feature(feature) ⇒ Object



12
13
14
15
16
# File 'lib/gurke/reporters/team_city_reporter.rb', line 12

def before_feature(feature)
  publish :testSuiteStarted, name: feature.name
  io.puts "  #{feature.description.split("\n").join("\n  ")}"
  io.puts
end

#before_scenario(scenario) ⇒ Object



18
19
20
21
# File 'lib/gurke/reporters/team_city_reporter.rb', line 18

def before_scenario(scenario)
  @scenario = scenario
  publish :testStarted, name: scenario.name
end

#before_step(step) ⇒ Object



35
36
37
38
39
40
# File 'lib/gurke/reporters/team_city_reporter.rb', line 35

def before_step(step, *)
  io.print '  ' if @background
  io.print '    '
  io.print step.keyword
  io.print step.name
end

#end_backgroundObject



31
32
33
# File 'lib/gurke/reporters/team_city_reporter.rb', line 31

def end_background(*)
  @background = false
end

#start_backgroundObject



23
24
25
26
27
28
29
# File 'lib/gurke/reporters/team_city_reporter.rb', line 23

def start_background(*)
  unless @background
    io.puts '    Background:'
  end

  @background = true
end