Class: RightSupport::CI::JavaSpecFormatter Deprecated
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- RightSupport::CI::JavaSpecFormatter
- Defined in:
- lib/right_support/ci/java_spec_formatter.rb,
lib/right_support/ci/java_spec_formatter.rb
Overview
Deprecated.
Please do not use this class
RSpec 2.x
Instance Method Summary collapse
- #classname_for(example) ⇒ Object
- #dump_failure(counter, failure) ⇒ Object
- #dump_pending ⇒ Object
- #dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object
- #example_failed(example) ⇒ Object
- #example_group_started(example) ⇒ Object
- #example_passed(example) ⇒ Object
- #example_pending(example) ⇒ Object
- #example_started(example) ⇒ Object
- #failure_details_for(example) ⇒ Object
-
#initialize(*args) ⇒ JavaSpecFormatter
constructor
A new instance of JavaSpecFormatter.
Constructor Details
#initialize(*args) ⇒ JavaSpecFormatter
Returns a new instance of JavaSpecFormatter.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 33 def initialize(*args) begin require 'builder' rescue LoadError => e raise NotImplementedError, "Your Gemfile or gemspec must include builder (~> 3.0) in order to use this class" end super(*args) @current_example_group = nil @test_times = {} @test_groups = {} @test_results = {} @test_failures = {} end |
Instance Method Details
#classname_for(example) ⇒ Object
117 118 119 120 121 122 123 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 117 def classname_for(example) # Take our best guess, by looking at the description of the example group # and assuming the first word is a class name group = @test_groups[example] klass = group.description.split(/\s+/).first "rspec.#{klass}" end |
#dump_failure(counter, failure) ⇒ Object
102 103 104 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 102 def dump_failure(counter, failure) # no-op; our summary contains everything end |
#dump_pending ⇒ Object
106 107 108 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 106 def dump_pending() # no-op; our summary contains everything end |
#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object
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 98 99 100 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 72 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_pair do |test, result| classname = classname_for(test) full_description = test.description # 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, :name => full_description, :time => @test_times[test]) do case result when "failed" builder.failure :message => "failed #{full_description}", :type => "failed" do builder.cdata! failure_details_for(test) end when "pending" then builder.skipped end end end end output.puts builder.target! end |
#example_failed(example) ⇒ Object
61 62 63 64 65 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 61 def example_failed(example, counter, failure) @test_times[example] = Time.now - @example_started_at @test_results[example] = 'failed' @test_failures[example] = failure end |
#example_group_started(example) ⇒ Object
47 48 49 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 47 def example_group_started(example) @current_example_group = example end |
#example_passed(example) ⇒ Object
56 57 58 59 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 56 def example_passed(example) @test_times[example] = Time.now - @example_started_at @test_results[example] = 'passed' end |
#example_pending(example) ⇒ Object
67 68 69 70 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 67 def example_pending(example, , deprecated_pending_location=nil) @test_times[example] = Time.now - @example_started_at @test_results[example] = 'pending' end |
#example_started(example) ⇒ Object
51 52 53 54 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 51 def example_started(example) @test_groups[example] = @current_example_group @example_started_at = Time.now end |
#failure_details_for(example) ⇒ Object
112 113 114 115 |
# File 'lib/right_support/ci/java_spec_formatter.rb', line 112 def failure_details_for(example) exception = @test_failures[example].exception exception.nil? ? "" : "#{exception.}\n#{format_backtrace(exception.backtrace)}" end |