Module: Allure
- Extended by:
- Allure
- Included in:
- Allure
- Defined in:
- lib/allure-ruby-commons.rb,
lib/allure_ruby_commons/config.rb,
lib/allure_ruby_commons/testplan.rb,
lib/allure_ruby_commons/model/link.rb,
lib/allure_ruby_commons/file_writer.rb,
lib/allure_ruby_commons/model/label.rb,
lib/allure_ruby_commons/model/stage.rb,
lib/allure_ruby_commons/_json_helper.rb,
lib/allure_ruby_commons/model/status.rb,
lib/allure_ruby_commons/result_utils.rb,
lib/allure_ruby_commons/model/globals.rb,
lib/allure_ruby_commons/model/category.rb,
lib/allure_ruby_commons/model/parameter.rb,
lib/allure_ruby_commons/allure_lifecycle.rb,
lib/allure_ruby_commons/model/attachment.rb,
lib/allure_ruby_commons/model/01_jsonable.rb,
lib/allure_ruby_commons/model/step_result.rb,
lib/allure_ruby_commons/model/test_result.rb,
lib/allure_ruby_commons/model/content_type.rb,
lib/allure_ruby_commons/model/global_error.rb,
lib/allure_ruby_commons/model/fixture_result.rb,
lib/allure_ruby_commons/model/status_details.rb,
lib/allure_ruby_commons/model/executable_item.rb,
lib/allure_ruby_commons/model/global_attachment.rb,
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: JsonHelper, ResultUtils Classes: AllureLifecycle, Attachment, Category, Config, ContentType, ExecutableItem, FileWriter, FixtureResult, GlobalAttachment, GlobalError, Globals, JSONable, Label, Link, Parameter, Stage, Status, StatusDetails, StepResult, TestPlan, TestResult, TestResultContainer
Class Method Summary collapse
-
.lifecycle=(lifecycle) ⇒ void
Set lifecycle object.
Instance Method Summary collapse
-
#add_attachment(name:, source:, type:, test_case: false) ⇒ void
Add attachment to current test case or step.
-
#add_categories(categories) ⇒ void
Manually create categories.json file if this method is called before test run started and option clean_results_directory is enabled, the file will be deleted.
-
#add_description(description) ⇒ void
Add description to current test case.
-
#add_environment(environment) ⇒ void
Manually create environment.properties file if this method is called before test run started and option clean_results_directory is enabled, the file will be deleted.
-
#add_global_attachment(name:, source:, type:) ⇒ void
Add run-level attachment not bound to a test or fixture.
-
#add_global_error(**details) ⇒ void
Add run-level error not bound to a test or fixture.
-
#add_link(url:, name: nil, type: "custom") ⇒ void
Add link to current test case.
-
#configuration ⇒ Config
Get allure configuration.
-
#configure {|| ... } ⇒ void
Set allure configuration.
-
#description_html(description_html) ⇒ void
Add html description to current test case.
-
#epic(value) ⇒ void
Add epic to current test case.
-
#feature(value) ⇒ void
Add feature to current test case.
-
#issue(name, url) ⇒ void
Add issue linkt to current test case.
-
#label(name, value) ⇒ void
Add label to current test case.
-
#lifecycle ⇒ AllureLifecycle
Get thread specific allure lifecycle object.
-
#parameter(name, value, excluded: false, mode: Allure::Parameter::DEFAULT) ⇒ void
Add parameter to current test case.
-
#replace_label(name, value) ⇒ void
Replace label in current test case.
-
#run_step(name) { ... } ⇒ Object
Run passed block as step with given name and return result of yield.
-
#set_flaky ⇒ void
Set test case status detail to flaky.
-
#set_known ⇒ void
Set test case status detail to known.
-
#set_muted ⇒ void
Set test case status detail to muted.
-
#step(name:, status: nil) ⇒ void
Add step with provided name and optional status to current test step, fixture or test case.
-
#step_parameter(name, value, excluded: false, mode: Allure::Parameter::DEFAULT) ⇒ void
Add parameter to current test step.
-
#story(value) ⇒ void
Add story to current test case.
-
#suite(value) ⇒ void
Add suite to current test case.
-
#tag(value) ⇒ void
Add tag to current test case.
-
#tms(name, url) ⇒ void
Add tms link to current test case.
Class Method Details
.lifecycle=(lifecycle) ⇒ void
This method returns an undefined value.
Set lifecycle object
15 16 17 |
# File 'lib/allure-ruby-commons.rb', line 15 def self.lifecycle=(lifecycle) Thread.current[:lifecycle] = lifecycle end |
Instance 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
161 162 163 |
# File 'lib/allure-ruby-commons.rb', line 161 def (name:, source:, type:, test_case: false) lifecycle.(name: name, source: source, type: type, test_case: test_case) end |
#add_categories(categories) ⇒ void
This method returns an undefined value.
Manually create categories.json file if this method is called before test run started and option clean_results_directory is enabled, the file will be deleted
200 201 202 |
# File 'lib/allure-ruby-commons.rb', line 200 def add_categories(categories) lifecycle.write_categories(categories) end |
#add_description(description) ⇒ void
This method returns an undefined value.
Add description to current test case
103 104 105 106 107 |
# File 'lib/allure-ruby-commons.rb', line 103 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.
Manually create environment.properties file if this method is called before test run started and option clean_results_directory is enabled, the file will be deleted
191 192 193 |
# File 'lib/allure-ruby-commons.rb', line 191 def add_environment(environment) lifecycle.write_environment(environment) end |
#add_global_attachment(name:, source:, type:) ⇒ void
This method returns an undefined value.
Add run-level attachment not bound to a test or fixture
170 171 172 |
# File 'lib/allure-ruby-commons.rb', line 170 def (name:, source:, type:) lifecycle.(name: name, source: source, type: type) end |
#add_global_error(**details) ⇒ void
This method returns an undefined value.
Add run-level error not bound to a test or fixture
182 183 184 |
# File 'lib/allure-ruby-commons.rb', line 182 def add_global_error(**details) lifecycle.add_global_error(**details) end |
#add_link(url:, name: nil, type: "custom") ⇒ void
This method returns an undefined value.
Add link to current test case
149 150 151 152 153 |
# File 'lib/allure-ruby-commons.rb', line 149 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 |
#configuration ⇒ Config
Get allure configuration
29 30 31 |
# File 'lib/allure-ruby-commons.rb', line 29 def configuration Config.instance end |
#configure {|| ... } ⇒ void
This method returns an undefined value.
Set allure configuration
37 38 39 |
# File 'lib/allure-ruby-commons.rb', line 37 def configure yield(configuration) end |
#description_html(description_html) ⇒ void
This method returns an undefined value.
Add html description to current test case
112 113 114 115 116 |
# File 'lib/allure-ruby-commons.rb', line 112 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
44 45 46 |
# File 'lib/allure-ruby-commons.rb', line 44 def epic(value) replace_label(ResultUtils::EPIC_LABEL_NAME, value) end |
#feature(value) ⇒ void
This method returns an undefined value.
Add feature to current test case
51 52 53 |
# File 'lib/allure-ruby-commons.rb', line 51 def feature(value) replace_label(ResultUtils::FEATURE_LABEL_NAME, value) end |
#issue(name, url) ⇒ void
This method returns an undefined value.
Add issue linkt to current test case
140 141 142 |
# File 'lib/allure-ruby-commons.rb', line 140 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
80 81 82 83 84 |
# File 'lib/allure-ruby-commons.rb', line 80 def label(name, value) lifecycle.update_test_case do |test_case| test_case.labels.push(Label.new(name, value)) end end |
#lifecycle ⇒ AllureLifecycle
Get thread specific allure lifecycle object
23 24 25 |
# File 'lib/allure-ruby-commons.rb', line 23 def lifecycle Thread.current[:lifecycle] ||= AllureLifecycle.new end |
#parameter(name, value, excluded: false, mode: Allure::Parameter::DEFAULT) ⇒ void
This method returns an undefined value.
Add parameter to current test case
122 123 124 125 126 |
# File 'lib/allure-ruby-commons.rb', line 122 def parameter(name, value, excluded: false, mode: Allure::Parameter::DEFAULT) lifecycle.update_test_case do |test_case| test_case.parameters.push(Parameter.new(name, value, excluded: excluded, mode: mode)) end end |
#replace_label(name, value) ⇒ void
This method returns an undefined value.
Replace label in current test case
91 92 93 94 95 96 97 98 |
# File 'lib/allure-ruby-commons.rb', line 91 def replace_label(name, value) lifecycle.update_test_case do |test_case| present = test_case.labels.detect { |l| l.name == name } return label(name, value) unless present test_case.labels.map! { |l| l.name == name ? Label.new(name, value) : l } end end |
#run_step(name) { ... } ⇒ Object
Run passed block as step with given name and return result of yield
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/allure-ruby-commons.rb', line 244 def run_step(name) lifecycle.start_test_step(StepResult.new(name: name, stage: Stage::RUNNING)) result = yield lifecycle.update_test_step { |step| step.status = Status::PASSED } result rescue StandardError, configuration.failure_exception => 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 |
#set_flaky ⇒ void
This method returns an undefined value.
Set test case status detail to flaky
207 208 209 210 211 |
# File 'lib/allure-ruby-commons.rb', line 207 def set_flaky lifecycle.update_test_case do |test_case| test_case.status_details.flaky = true end end |
#set_known ⇒ void
This method returns an undefined value.
Set test case status detail to known
225 226 227 228 229 |
# File 'lib/allure-ruby-commons.rb', line 225 def set_known lifecycle.update_test_case do |test_case| test_case.status_details.known = true end end |
#set_muted ⇒ void
This method returns an undefined value.
Set test case status detail to muted
216 217 218 219 220 |
# File 'lib/allure-ruby-commons.rb', line 216 def set_muted lifecycle.update_test_case do |test_case| test_case.status_details.muted = true end 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
235 236 237 238 |
# File 'lib/allure-ruby-commons.rb', line 235 def step(name:, status: nil) lifecycle.add_test_step(StepResult.new(name: name, status: status || Status::PASSED, stage: Stage::FINISHED)) lifecycle.stop_test_step end |
#step_parameter(name, value, excluded: false, mode: Allure::Parameter::DEFAULT) ⇒ void
This method returns an undefined value.
Add parameter to current test step
264 265 266 267 268 |
# File 'lib/allure-ruby-commons.rb', line 264 def step_parameter(name, value, excluded: false, mode: Allure::Parameter::DEFAULT) lifecycle.update_test_step do |step| step.parameters.push(Parameter.new(name, value, excluded: excluded, mode: mode)) end end |
#story(value) ⇒ void
This method returns an undefined value.
Add story to current test case
58 59 60 |
# File 'lib/allure-ruby-commons.rb', line 58 def story(value) replace_label(ResultUtils::STORY_LABEL_NAME, value) end |
#suite(value) ⇒ void
This method returns an undefined value.
Add suite to current test case
65 66 67 |
# File 'lib/allure-ruby-commons.rb', line 65 def suite(value) replace_label(ResultUtils::SUITE_LABEL_NAME, value) end |
#tag(value) ⇒ void
This method returns an undefined value.
Add tag to current test case
72 73 74 |
# File 'lib/allure-ruby-commons.rb', line 72 def tag(value) label(ResultUtils::TAG_LABEL_NAME, value) end |
#tms(name, url) ⇒ void
This method returns an undefined value.
Add tms link to current test case
132 133 134 |
# File 'lib/allure-ruby-commons.rb', line 132 def tms(name, url) add_link(name: name, url: url, type: ResultUtils::TMS_LINK_TYPE) end |