Module: Allure::ResultUtils
- Defined in:
- lib/allure_ruby_commons/result_utils.rb
Overview
Variouse helper methods
Constant Summary collapse
- ISSUE_LINK_TYPE =
"issue"
- TMS_LINK_TYPE =
"tms"
- ALLURE_ID_LABEL_NAME =
"AS_ID"
- SUITE_LABEL_NAME =
"suite"
- PARENT_SUITE_LABEL_NAME =
"parentSuite"
- SUB_SUITE_LABEL_NAME =
"subSuite"
- EPIC_LABEL_NAME =
"epic"
- FEATURE_LABEL_NAME =
"feature"
- STORY_LABEL_NAME =
"story"
- SEVERITY_LABEL_NAME =
"severity"
- TAG_LABEL_NAME =
"tag"
- OWNER_LABEL_NAME =
"owner"
- LEAD_LABEL_NAME =
"lead"
- HOST_LABEL_NAME =
"host"
- THREAD_LABEL_NAME =
"thread"
- TEST_METHOD_LABEL_NAME =
"testMethod"
- TEST_CLASS_LABEL_NAME =
"testClass"
- PACKAGE_LABEL_NAME =
"package"
- FRAMEWORK_LABEL_NAME =
"framework"
- LANGUAGE_LABEL_NAME =
"language"
Class Method Summary collapse
-
.epic_label(value) ⇒ Allure::Label
Epic label.
-
.feature_label(value) ⇒ Allure::Label
Feature label.
-
.framework_label(value) ⇒ Allure::Label
Framework label.
-
.host_label ⇒ Allure::Label
Host label.
-
.issue_link(name, value, link_pattern) ⇒ Allure::Link
Issue link.
-
.language_label ⇒ Allure::Label
Language label.
-
.package_label(value) ⇒ Allure::Label
Package label.
-
.parent_suite_label(value) ⇒ Allure::Label
Parent suite label.
-
.prepare_attachment(name, type) ⇒ Allure::Attachment
Allure attachment object.
-
.severity_label(value) ⇒ Allure::Label
Severity label.
-
.status(exception) ⇒ Symbol
Get status based on exception type.
-
.status_details(exception) ⇒ Allure::StatusDetails
Get exception status detail.
-
.story_label(value) ⇒ Allure::Label
Story label.
-
.sub_suite_label(value) ⇒ Allure::Label
Parent suite label.
-
.suite_label(value) ⇒ Allure::Label
Suite label.
-
.tag_label(value) ⇒ Allure::Label
Tag label.
-
.test_class_label(value) ⇒ Allure::Label
Test case label.
-
.thread_label ⇒ Allure::Label
Current thread label.
- .timestamp(time = nil) ⇒ Number
-
.tms_link(name, value, link_pattern) ⇒ Allure::Link
TMS link.
Class Method Details
.epic_label(value) ⇒ Allure::Label
Epic label
66 67 68 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 66 def epic_label(value) Label.new(EPIC_LABEL_NAME, value) end |
.feature_label(value) ⇒ Allure::Label
Feature label
73 74 75 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 73 def feature_label(value) Label.new(FEATURE_LABEL_NAME, value) end |
.framework_label(value) ⇒ Allure::Label
Framework label
59 60 61 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 59 def framework_label(value) Label.new(FRAMEWORK_LABEL_NAME, value) end |
.host_label ⇒ Allure::Label
Host label
46 47 48 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 46 def host_label Label.new(HOST_LABEL_NAME, Socket.gethostname) end |
.issue_link(name, value, link_pattern) ⇒ Allure::Link
Issue link
146 147 148 149 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 146 def issue_link(name, value, link_pattern) link_name = url?(value) ? name : value Link.new(ISSUE_LINK_TYPE, link_name, url(value, link_pattern)) end |
.language_label ⇒ Allure::Label
Language label
52 53 54 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 52 def language_label Label.new(LANGUAGE_LABEL_NAME, "ruby") end |
.package_label(value) ⇒ Allure::Label
Package label
87 88 89 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 87 def package_label(value) Label.new(PACKAGE_LABEL_NAME, value) end |
.parent_suite_label(value) ⇒ Allure::Label
Parent suite label
101 102 103 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 101 def parent_suite_label(value) Label.new(PARENT_SUITE_LABEL_NAME, value) end |
.prepare_attachment(name, type) ⇒ Allure::Attachment
Allure attachment object
169 170 171 172 173 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 169 def (name, type) extension = ContentType.to_extension(type) || return file_name = "#{SecureRandom.uuid}-attachment.#{extension}" Attachment.new(name: name, source: file_name, type: type) end |
.severity_label(value) ⇒ Allure::Label
Severity label
129 130 131 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 129 def severity_label(value) Label.new(SEVERITY_LABEL_NAME, value) end |
.status(exception) ⇒ Symbol
Get status based on exception type
154 155 156 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 154 def status(exception) exception.is_a?(Allure.configuration.failure_exception) ? Status::FAILED : Status::BROKEN end |
.status_details(exception) ⇒ Allure::StatusDetails
Get exception status detail
161 162 163 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 161 def status_details(exception) StatusDetails.new(message: exception&., trace: exception&.backtrace&.join("\n")) end |
.story_label(value) ⇒ Allure::Label
Story label
80 81 82 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 80 def story_label(value) Label.new(STORY_LABEL_NAME, value) end |
.sub_suite_label(value) ⇒ Allure::Label
Parent suite label
108 109 110 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 108 def sub_suite_label(value) Label.new(SUB_SUITE_LABEL_NAME, value) end |
.suite_label(value) ⇒ Allure::Label
Suite label
94 95 96 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 94 def suite_label(value) Label.new(SUITE_LABEL_NAME, value) end |
.tag_label(value) ⇒ Allure::Label
Tag label
122 123 124 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 122 def tag_label(value) Label.new(TAG_LABEL_NAME, value) end |
.test_class_label(value) ⇒ Allure::Label
Test case label
115 116 117 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 115 def test_class_label(value) Label.new(TEST_CLASS_LABEL_NAME, value) end |
.thread_label ⇒ Allure::Label
Current thread label
40 41 42 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 40 def thread_label Label.new(THREAD_LABEL_NAME, Thread.current.object_id) end |
.timestamp(time = nil) ⇒ Number
34 35 36 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 34 def (time = nil) ((time || Time.now).to_f * 1000).to_i end |
.tms_link(name, value, link_pattern) ⇒ Allure::Link
TMS link
137 138 139 140 |
# File 'lib/allure_ruby_commons/result_utils.rb', line 137 def tms_link(name, value, link_pattern) link_name = url?(value) ? name : value Link.new(TMS_LINK_TYPE, link_name, url(value, link_pattern)) end |