Class: Buildr::JtestR::ResultHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/buildr/java/jtestr_result.rb

Overview

A JtestR ResultHandler Using this handler we can use RSpec formatters, like html/ci_reporter with JtestR Created for JTestrYamlFormatter

Defined Under Namespace

Modules: ExampleMethods, TestNGResultHandlerMixin Classes: BacktraceTweaker

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, desc, *args) ⇒ ResultHandler

Returns a new instance of ResultHandler.



151
152
153
154
155
156
157
158
159
160
161
# File 'lib/buildr/java/jtestr_result.rb', line 151

def initialize(name, desc, *args)
  self.example_group = ::Spec::Example::ExampleGroup.new(desc)
  example_group.extend ExampleMethods
  example_group.name = name.to_s
  if example_group.name[/Spec/]
    example_group.description = desc.to_s
  else
    example_group.description = name.to_s
  end
  reporter.example_group_started(example_group)
end

Class Attribute Details

.reporterObject (readonly)

an rspec reporter used to proxy events to rspec formatters



119
120
121
# File 'lib/buildr/java/jtestr_result.rb', line 119

def reporter
  @reporter
end

.test_filesObject

Returns the value of attribute test_files.



120
121
122
# File 'lib/buildr/java/jtestr_result.rb', line 120

def test_files
  @test_files
end

Instance Attribute Details

#current_exampleObject

Returns the value of attribute current_example.



149
150
151
# File 'lib/buildr/java/jtestr_result.rb', line 149

def current_example
  @current_example
end

#current_failureObject

Returns the value of attribute current_failure.



149
150
151
# File 'lib/buildr/java/jtestr_result.rb', line 149

def current_failure
  @current_failure
end

#example_groupObject

Returns the value of attribute example_group.



149
150
151
# File 'lib/buildr/java/jtestr_result.rb', line 149

def example_group
  @example_group
end

Class Method Details

.afterObject



134
135
136
137
# File 'lib/buildr/java/jtestr_result.rb', line 134

def after
  reporter.end
  reporter.dump
end

.beforeObject



130
131
132
# File 'lib/buildr/java/jtestr_result.rb', line 130

def before
  reporter.start(reporter.options.files.size)
end

.init(argv = [], out = STDOUT, err = STDERR) ⇒ Object



122
123
124
125
126
127
128
# File 'lib/buildr/java/jtestr_result.rb', line 122

def init(argv = [], out = STDOUT, err = STDERR)
  ::JtestR::TestNGResultHandler.module_eval { include TestNGResultHandlerMixin }
  rspec_parser = ::Spec::Runner::OptionParser.new(err, out)
  rspec_parser.order!(argv)
  rspec_parser.options.backtrace_tweaker = BacktraceTweaker.new
  @reporter = Spec::Runner::Reporter.new(rspec_parser.options)
end

Instance Method Details

#add_fault(fault) ⇒ Object



170
171
172
# File 'lib/buildr/java/jtestr_result.rb', line 170

def add_fault(fault)
  self.current_failure = fault
end

#add_pending(pending) ⇒ Object



174
175
# File 'lib/buildr/java/jtestr_result.rb', line 174

def add_pending(pending)
end

#endingObject



167
168
# File 'lib/buildr/java/jtestr_result.rb', line 167

def ending
end

#error_single(name = nil) ⇒ Object



203
204
205
206
# File 'lib/buildr/java/jtestr_result.rb', line 203

def error_single(name = nil)
  current_example.name = current_name
  reporter.example_finished(current_example, current_error)
end

#fail_single(name = nil) ⇒ Object



198
199
200
201
# File 'lib/buildr/java/jtestr_result.rb', line 198

def fail_single(name = nil)
  current_example.name = current_name
  reporter.example_finished(current_example, current_error)
end

#pending_single(name = nil) ⇒ Object



208
209
210
211
# File 'lib/buildr/java/jtestr_result.rb', line 208

def pending_single(name = nil)
  error = ::Spec::Example::ExamplePendingError.new(name)
  reporter.example_finished(current_example, error)
end

#reporterObject



145
146
147
# File 'lib/buildr/java/jtestr_result.rb', line 145

def reporter
  self.class.reporter
end

#startingObject



164
165
# File 'lib/buildr/java/jtestr_result.rb', line 164

def starting
end

#starting_single(name = nil) ⇒ Object



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/buildr/java/jtestr_result.rb', line 177

def starting_single(name = nil)
  self.current_failure = nil
  self.current_example = Object.new
  current_example.extend ::Spec::Example::ExampleMethods
  current_example.extend ExampleMethods
  name = name.to_s
  current_example.location = name.to_s
  current_example.name = name.gsub(/(.*)\((.+)\)/, '\2')
  current_example.description = name
  if example_group.name[/Spec/]
    current_example.__full_description = "#{example_group.description} #{name}"
  else
    current_example.__full_description = "#{example_group.name}: #{name}"
  end
  reporter.example_started(current_example)
end

#succeed_single(name = nil) ⇒ Object



194
195
196
# File 'lib/buildr/java/jtestr_result.rb', line 194

def succeed_single(name = nil)
  reporter.example_finished(current_example, nil)
end