Module: AllureCucumber::AllureCucumberModel

Includes:
AstTransformer, TagParser
Included in:
CucumberFormatter
Defined in:
allure-cucumber/lib/allure_cucumber/cucumber_model.rb

Overview

Support class for transforming cucumber test entities in to allure model entities

Instance Method Summary collapse

Methods included from TagParser

#issue_links, #severity, #status_detail_tags, #tag_labels, #tms_links

Methods included from AstTransformer

#example_row, #multiline_arg, #scenario, #step

Instance Method Details

#failure_details(result) ⇒ Hash<Symbol, String>

Get failure details

Parameters:

  • result (Cucumber::Core::Test::Result)

    <description>

Returns:

  • (Hash<Symbol, String>)

55
56
57
58
59
60
# File 'allure-cucumber/lib/allure_cucumber/cucumber_model.rb', line 55

def failure_details(result)
  return { message: result.exception.message, trace: result.exception.backtrace.join("\n") } if result.failed?
  return { message: result.message, trace: result.backtrace.join("\n") } if result.undefined?

  {}
end

#fixture_result(test_step) ⇒ StepResult

Convert to allure step result

Parameters:

  • test_step (Cucumber::Core::Test::Step)

Returns:

  • (StepResult)

47
48
49
50
# File 'allure-cucumber/lib/allure_cucumber/cucumber_model.rb', line 47

def fixture_result(test_step)
  location = test_step.location.to_s.split("/").last
  Allure::FixtureResult.new(name: location)
end

#lifecycleAllure::AllureLifecycle

Get thread specific lifecycle


64
65
66
# File 'allure-cucumber/lib/allure_cucumber/cucumber_model.rb', line 64

def lifecycle
  Allure.lifecycle
end

#step_result(test_step) ⇒ StepResult

Convert to allure step result

Parameters:

  • test_step (Cucumber::Core::Test::Step)

Returns:

  • (StepResult)

37
38
39
40
41
42
# File 'allure-cucumber/lib/allure_cucumber/cucumber_model.rb', line 37

def step_result(test_step)
  Allure::StepResult.new(
    name: "#{step(test_step).keyword}#{test_step.text}",
    attachments: [multiline_arg_attachment(test_step)].compact,
  )
end

#test_result(test_case) ⇒ TestResult

Convert to allure test result

Parameters:

  • test_case (Cucumber::Core::Test::Case)

Returns:

  • (TestResult)

20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'allure-cucumber/lib/allure_cucumber/cucumber_model.rb', line 20

def test_result(test_case)
  Allure::TestResult.new(
    name: test_case.name,
    description: description(test_case),
    description_html: description(test_case),
    history_id: Digest::MD5.hexdigest(test_case.inspect),
    full_name: "#{test_case.feature.name}: #{test_case.name}",
    labels: labels(test_case),
    links: links(test_case),
    parameters: parameters(test_case) || [],
    status_details: Allure::StatusDetails.new(**status_detail_tags(test_case.tags.map(&:name))),
  )
end