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/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/fixture_result.rb,
lib/allure_ruby_commons/model/status_details.rb,
lib/allure_ruby_commons/model/executable_item.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, 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_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) ⇒ 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) ⇒ 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
14 15 16 |
# File 'lib/allure-ruby-commons.rb', line 14 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
160 161 162 |
# File 'lib/allure-ruby-commons.rb', line 160 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
178 179 180 |
# File 'lib/allure-ruby-commons.rb', line 178 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
102 103 104 105 106 |
# File 'lib/allure-ruby-commons.rb', line 102 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
169 170 171 |
# File 'lib/allure-ruby-commons.rb', line 169 def add_environment(environment) lifecycle.write_environment(environment) end |
#add_link(url:, name: nil, type: "custom") ⇒ void
This method returns an undefined value.
Add link to current test case
148 149 150 151 152 |
# File 'lib/allure-ruby-commons.rb', line 148 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
28 29 30 |
# File 'lib/allure-ruby-commons.rb', line 28 def configuration Config.instance end |
#configure {|| ... } ⇒ void
This method returns an undefined value.
Set allure configuration
36 37 38 |
# File 'lib/allure-ruby-commons.rb', line 36 def configure yield(configuration) end |
#description_html(description_html) ⇒ void
This method returns an undefined value.
Add html description to current test case
111 112 113 114 115 |
# File 'lib/allure-ruby-commons.rb', line 111 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
43 44 45 |
# File 'lib/allure-ruby-commons.rb', line 43 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
50 51 52 |
# File 'lib/allure-ruby-commons.rb', line 50 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
139 140 141 |
# File 'lib/allure-ruby-commons.rb', line 139 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
79 80 81 82 83 |
# File 'lib/allure-ruby-commons.rb', line 79 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
22 23 24 |
# File 'lib/allure-ruby-commons.rb', line 22 def lifecycle Thread.current[:lifecycle] ||= AllureLifecycle.new end |
#parameter(name, value) ⇒ void
This method returns an undefined value.
Add parameter to current test case
121 122 123 124 125 |
# File 'lib/allure-ruby-commons.rb', line 121 def parameter(name, value) lifecycle.update_test_case do |test_case| test_case.parameters.push(Parameter.new(name, value)) end end |
#replace_label(name, value) ⇒ void
This method returns an undefined value.
Replace label in current test case
90 91 92 93 94 95 96 97 |
# File 'lib/allure-ruby-commons.rb', line 90 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
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/allure-ruby-commons.rb', line 222 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
185 186 187 188 189 |
# File 'lib/allure-ruby-commons.rb', line 185 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
203 204 205 206 207 |
# File 'lib/allure-ruby-commons.rb', line 203 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
194 195 196 197 198 |
# File 'lib/allure-ruby-commons.rb', line 194 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
213 214 215 216 |
# File 'lib/allure-ruby-commons.rb', line 213 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) ⇒ void
This method returns an undefined value.
Add parameter to current test step
242 243 244 245 246 |
# File 'lib/allure-ruby-commons.rb', line 242 def step_parameter(name, value) lifecycle.update_test_step do |step| step.parameters.push(Parameter.new(name, value)) end end |
#story(value) ⇒ void
This method returns an undefined value.
Add story to current test case
57 58 59 |
# File 'lib/allure-ruby-commons.rb', line 57 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
64 65 66 |
# File 'lib/allure-ruby-commons.rb', line 64 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
71 72 73 |
# File 'lib/allure-ruby-commons.rb', line 71 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
131 132 133 |
# File 'lib/allure-ruby-commons.rb', line 131 def tms(name, url) add_link(name: name, url: url, type: ResultUtils::TMS_LINK_TYPE) end |