Class: Cucumber::Formatter::LegacyApi::Adapter::FeaturePrinter

Inherits:
Struct
  • Object
show all
Defined in:
lib/cucumber/formatter/legacy_api/adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_test_step_sourceObject (readonly)

Returns the value of attribute current_test_step_source


237
238
239
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 237

def current_test_step_source
  @current_test_step_source
end

Instance Method Details

#afterObject


320
321
322
323
324
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 320

def after
  @child.after if @child
  formatter.after_feature(node)
  self
end

#after_hook(_location, result) ⇒ Object


283
284
285
286
287
288
289
290
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 283

def after_hook(_location, result)
  # if the scenario has no steps, we can hit this before we've created the scenario printer
  # ideally we should call switch_step_container in before_step_step
  switch_step_container if !@child
  @child.after_hook Ast::HookResult.new(LegacyResultBuilder.new(result), @delayed_messages, @delayed_embeddings)
  @delayed_messages = []
  @delayed_embeddings = []
end

#after_step_hook(_hook, result) ⇒ Object


292
293
294
295
296
297
298
299
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 292

def after_step_hook(_hook, result)
  p current_test_step_source if current_test_step_source.step.nil?
  line = current_test_step_source.step.backtrace_line
  @child.after_step_hook Ast::HookResult.new(LegacyResultBuilder.new(result).
    append_to_exception_backtrace(line), @delayed_messages, @delayed_embeddings)
  @delayed_messages = []
  @delayed_embeddings = []
end

#after_test_case(test_case, test_case_result) ⇒ Object


255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 255

def after_test_case(test_case, test_case_result)
  if current_test_step_source && current_test_step_source.step_result.nil?
    switch_step_container
  end

  if test_case_result.failed? && !any_test_steps_failed?
    # around hook must have failed. Print the error.
    switch_step_container(TestCaseSource.for(test_case, test_case_result))
    LegacyResultBuilder.new(test_case_result).describe_exception_to formatter
  end

  # messages and embedding should already have been handled, but just in case...
  @delayed_messages.each { |message| formatter.puts(message) }
  @delayed_embeddings.each { |embedding| embedding.send_to_formatter(formatter) }
  @delayed_messages = []
  @delayed_embeddings = []

  @child.after_test_case(test_case, test_case_result) if @child
  @previous_test_case_background = @current_test_case_background
  @previous_test_case_scenario_outline = current_test_step_source && current_test_step_source.scenario_outline
end

#after_test_step(test_step, result) ⇒ Object


247
248
249
250
251
252
253
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 247

def after_test_step(test_step, result)
  @current_test_step_source = TestStepSource.for(test_step, result)
  # TODO: stop calling self, and describe source to another object
  test_step.describe_source_to(self, result)
  print_step
  @test_step_results << result
end

#background(node) ⇒ Object


301
302
303
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 301

def background(node, *)
  @current_test_case_background = node
end

#beforeObject


226
227
228
229
230
231
232
233
234
235
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 226

def before
  formatter.before_feature(node)
  language_comment = node.language.iso_code != 'en' ? ["# language: #{node.language.iso_code}"] : []
  Ast::Comments.new(language_comment + node.comments).accept(formatter)
  Ast::Tags.new(node.tags).accept(formatter)
  formatter.feature_name node.keyword, node.legacy_conflated_name_and_description
  @delayed_messages = []
  @delayed_embeddings = []
  self
end

#before_hook(_location, result) ⇒ Object


277
278
279
280
281
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 277

def before_hook(_location, result)
  @before_hook_results << Ast::HookResult.new(LegacyResultBuilder.new(result), @delayed_messages, @delayed_embeddings)
  @delayed_messages = []
  @delayed_embeddings = []
end

#before_test_case(_test_case) ⇒ Object


239
240
241
242
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 239

def before_test_case(_test_case)
  @before_hook_results = Ast::HookResultCollection.new
  @test_step_results = []
end

#before_test_step(test_step) ⇒ Object


244
245
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 244

def before_test_step(test_step)
end

#embed(src, mime_type, label) ⇒ Object


309
310
311
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 309

def embed(src, mime_type, label)
  @delayed_embeddings.push Embedding.new(src, mime_type, label)
end

#examples_tableObject


316
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 316

def examples_table(*);end

#examples_table_rowObject


317
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 317

def examples_table_row(*);end

#featureObject


318
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 318

def feature(*);end

#puts(messages) ⇒ Object


305
306
307
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 305

def puts(messages)
  @delayed_messages.push *messages
end

#scenarioObject


314
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 314

def scenario(*);end

#scenario_outlineObject


315
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 315

def scenario_outline(*);end

#stepObject


313
# File 'lib/cucumber/formatter/legacy_api/adapter.rb', line 313

def step(*);end