Module: Allure

Defined in:
allure-ruby-commons/lib/allure-ruby-commons.rb,
allure-ruby-commons/lib/allure_ruby_commons/config.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/link.rb,
allure-ruby-commons/lib/allure_ruby_commons/file_writer.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/label.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/stage.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/status.rb,
allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/jsonable.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/parameter.rb,
allure-ruby-commons/lib/allure_ruby_commons/allure_lifecycle.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/attachment.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/step_result.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/test_result.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/content_type.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/fixture_result.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/status_details.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/executable_item.rb,
allure-ruby-commons/lib/allure_ruby_commons/model/test_result_container.rb

Overview

Namespace for classes that handle allure report generation and different framework adaptors

Defined Under Namespace

Modules: ResultUtils Classes: AllureLifecycle, Attachment, Config, ContentType, ExecutableItem, FileWriter, FixtureResult, JSONable, Label, Link, Parameter, Stage, Status, StatusDetails, StepResult, TestResult, TestResultContainer

Class Method Summary collapse

Class Method Details

.add_attachment(name:, source:, type:, test_case: false) ⇒ void

This method returns an undefined value.

Add attachment to current test case or step


137
138
139
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 137

def add_attachment(name:, source:, type:, test_case: false)
  lifecycle.add_attachment(name: name, source: source, type: type, test_case: test_case)
end

.add_description(description) ⇒ void

This method returns an undefined value.

Add description to current test case


79
80
81
82
83
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 79

def add_description(description)
  lifecycle.update_test_case do |test_case|
    test_case.description = description
  end
end

.add_environment(environment) ⇒ void

This method returns an undefined value.

Write allure report environment info


144
145
146
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 144

def add_environment(environment)
  lifecycle.write_environment(environment)
end

This method returns an undefined value.

Add link to current test case


125
126
127
128
129
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 125

def add_link(url:, name: nil, type: "custom")
  lifecycle.update_test_case do |test_case|
    test_case.links.push(Link.new(type, name || url, url))
  end
end

.configurationAllure::Config

Get allure configuration


26
27
28
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 26

def configuration
  Config
end

.configure {|| ... } ⇒ void

This method returns an undefined value.

Set allure configuration

Yield Parameters:

Yield Returns:

  • (void)

34
35
36
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 34

def configure
  yield(Config)
end

.description_html(description_html) ⇒ void

This method returns an undefined value.

Add html description to current test case


88
89
90
91
92
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 88

def description_html(description_html)
  lifecycle.update_test_case do |test_case|
    test_case.description_html = description_html
  end
end

.epic(value) ⇒ void

This method returns an undefined value.

Add epic to current test case


41
42
43
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 41

def epic(value)
  label(ResultUtils::EPIC_LABEL_NAME, value)
end

.feature(value) ⇒ void

This method returns an undefined value.

Add feature to current test case


48
49
50
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 48

def feature(value)
  label(ResultUtils::FEATURE_LABEL_NAME, value)
end

.issue(name, url) ⇒ void

This method returns an undefined value.

Add issue linkt to current test case


116
117
118
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 116

def issue(name, url)
  add_link(name: name, url: url, type: ResultUtils::ISSUE_LINK_TYPE)
end

.label(name, value) ⇒ void

This method returns an undefined value.

Add label to current test case


70
71
72
73
74
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 70

def label(name, value)
  lifecycle.update_test_case do |test_case|
    test_case.labels.push(Label.new(name, value))
  end
end

.lifecycleAllure::AllureLifecycle

Get thread specific allure lifecycle object


13
14
15
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 13

def lifecycle
  Thread.current[:lifecycle] ||= AllureLifecycle.new
end

.lifecycle=(lifecycle) ⇒ void

This method returns an undefined value.

Set lifecycle object


20
21
22
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 20

def lifecycle=(lifecycle)
  Thread.current[:lifecycle] = lifecycle
end

.parameter(name, value) ⇒ void

This method returns an undefined value.

Add parameter to current test case


98
99
100
101
102
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 98

def parameter(name, value)
  lifecycle.update_test_case do |test_case|
    test_case.parameters.push(Parameter.new(name, value))
  end
end

.run_step(name) { ... } ⇒ void

This method returns an undefined value.

Run passed block as step with given name

Yields:

  • step block


160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 160

def run_step(name)
  lifecycle.start_test_step(StepResult.new(name: name, stage: Stage::RUNNING))
  yield
  lifecycle.update_test_step { |step| step.status = Status::PASSED }
rescue => e
  lifecycle.update_test_step do |step|
    step.status = ResultUtils.status(e)
    step.status_details = ResultUtils.status_details(e)
  end
  raise(e)
ensure
  lifecycle.stop_test_step
end

.step(name:, status: nil) ⇒ void

This method returns an undefined value.

Add step with provided name and optional status to current test step, fixture or test case


152
153
154
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 152

def step(name:, status: nil)
  lifecycle.add_test_step(StepResult.new(name: name, status: status || Status::PASSED, stage: Stage::FINISHED))
end

.story(value) ⇒ void

This method returns an undefined value.

Add story to current test case


55
56
57
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 55

def story(value)
  label(ResultUtils::STORY_LABEL_NAME, value)
end

.suite(value) ⇒ void

This method returns an undefined value.

Add suite to current test case


62
63
64
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 62

def suite(value)
  label(ResultUtils::SUITE_LABEL_NAME, value)
end

.tms(name, url) ⇒ void

This method returns an undefined value.

Add tms link to current test case


108
109
110
# File 'allure-ruby-commons/lib/allure-ruby-commons.rb', line 108

def tms(name, url)
  add_link(name: name, url: url, type: ResultUtils::TMS_LINK_TYPE)
end