Class: RightDevelop::CI::JavaSpecFormatter

Inherits:
Spec::Runner::Formatter::BaseTextFormatter
  • Object
show all
Defined in:
lib/right_develop/ci/java_spec_formatter.rb,
lib/right_develop/ci/java_spec_formatter.rb

Overview

RSpec 1.x

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ JavaSpecFormatter

Returns a new instance of JavaSpecFormatter.



40
41
42
43
# File 'lib/right_develop/ci/java_spec_formatter.rb', line 40

def initialize(*args)
  super(*args)
  @test_results = []
end

Instance Method Details

#dump_failure(counter, failure) ⇒ Object



173
174
175
# File 'lib/right_develop/ci/java_spec_formatter.rb', line 173

def dump_failure(counter, failure)
  # no-op; our summary contains everything
end

#dump_pendingObject



177
178
179
# File 'lib/right_develop/ci/java_spec_formatter.rb', line 177

def dump_pending()
  # no-op; our summary contains everything
end

#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/right_develop/ci/java_spec_formatter.rb', line 68

def dump_summary(duration, example_count, failure_count, pending_count)
  builder = Builder::XmlMarkup.new :indent => 2
  builder.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
  builder.testsuite :errors => 0, :failures => failure_count, :skipped => pending_count, :tests => example_count, :time => duration, :timestamp => Time.now.iso8601 do
    builder.properties
    @test_results.each do |test|
      classname        = purify(classname_for(test))
      full_description = purify(test.full_description)
      time             = test.[:execution_result][:run_time]

      # The full description always begins with the classname, but this is useless info when
      # generating the XML report.
      if full_description.start_with?(classname)
        full_description = full_description[classname.length..-1].strip
      end

      builder.testcase(:classname => classname.to_sym, :name => full_description, :time => time) do
        case test.[:execution_result][:status]
        when "failed"
          builder.failure :message => "failed #{full_description}", :type => "failed" do
            builder.cdata! purify(failure_details_for(test))
          end
        when "pending" then
          builder.skipped
        end
      end
    end
  end
  output.puts builder.target!
end

#example_failed(example, counter, failure) ⇒ Object



49
50
51
# File 'lib/right_develop/ci/java_spec_formatter.rb', line 49

def example_failed(example)
  @test_results << example
end

#example_group_started(example) ⇒ Object



115
116
117
# File 'lib/right_develop/ci/java_spec_formatter.rb', line 115

def example_group_started(example)
  @current_example_group = example
end

#example_passed(example) ⇒ Object



45
46
47
# File 'lib/right_develop/ci/java_spec_formatter.rb', line 45

def example_passed(example)
  @test_results << example
end

#example_pending(example, message, deprecated_pending_location = nil) ⇒ Object



53
54
55
# File 'lib/right_develop/ci/java_spec_formatter.rb', line 53

def example_pending(example)
  @test_results << example
end

#example_started(example) ⇒ Object



119
120
121
122
# File 'lib/right_develop/ci/java_spec_formatter.rb', line 119

def example_started(example)
  @test_groups[example] ||= @current_example_group
  @example_started_at = Time.now
end