Module: Allure::ResultUtils

Defined in:
allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb

Overview

Variouse helper methods

Constant Summary collapse

"issue"
"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

Class Method Details

.feature_label(value) ⇒ Allure::Label

Feature label

Parameters:

  • value (String)

Returns:


60
61
62
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 60

def feature_label(value)
  Label.new(FEATURE_LABEL_NAME, value)
end

.framework_label(value) ⇒ Object


53
54
55
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 53

def framework_label(value)
  Label.new(FRAMEWORK_LABEL_NAME, value)
end

.host_labelAllure::Label

Host label

Returns:


45
46
47
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 45

def host_label
  Label.new(HOST_LABEL_NAME, Socket.gethostname)
end

Issue link

Parameters:

  • value (String)

Returns:


130
131
132
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 130

def issue_link(value)
  Link.new(ISSUE_LINK_TYPE, value, issue_url(value))
end

.language_labelObject


49
50
51
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 49

def language_label
  Label.new(LANGUAGE_LABEL_NAME, "ruby")
end

.package_label(value) ⇒ Allure::Label

Package label

Parameters:

  • value (String)

Returns:


67
68
69
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 67

def package_label(value)
  Label.new(PACKAGE_LABEL_NAME, value)
end

.parent_suite_label(value) ⇒ Allure::Label

Parent suite label

Parameters:

  • value (String)

Returns:


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

def parent_suite_label(value)
  Label.new(PARENT_SUITE_LABEL_NAME, value)
end

.severity_label(value) ⇒ Allure::Label

Severity label

Parameters:

  • value (String)

Returns:


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

def severity_label(value)
  Label.new(SEVERITY_LABEL_NAME, value)
end

.status(exception) ⇒ Symbol

Get status based on exception type

Parameters:

  • exception (Exception)

Returns:

  • (Symbol)

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

def status(exception)
  exception.is_a?(RSpec::Expectations::ExpectationNotMetError) ? Status::FAILED : Status::BROKEN
end

.status_details(exception) ⇒ Allure::StatusDetails

Get exception status detail

Parameters:

  • exception (Exception)

Returns:


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

def status_details(exception)
  StatusDetails.new(message: exception&.message, trace: exception&.backtrace&.join("\n"))
end

.story_label(value) ⇒ Allure::Label

Story label

Parameters:

  • value (String)

Returns:


95
96
97
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 95

def (value)
  Label.new(STORY_LABEL_NAME, value)
end

.sub_suite_label(value) ⇒ Allure::Label

Parent suite label

Parameters:

  • value (String)

Returns:


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

def sub_suite_label(value)
  Label.new(SUB_SUITE_LABEL_NAME, value)
end

.suite_label(value) ⇒ Allure::Label

Suite label

Parameters:

  • value (String)

Returns:


74
75
76
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 74

def suite_label(value)
  Label.new(SUITE_LABEL_NAME, value)
end

.tag_label(value) ⇒ Allure::Label

Tag label

Parameters:

  • value (String)

Returns:


109
110
111
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 109

def tag_label(value)
  Label.new(TAG_LABEL_NAME, value)
end

.test_class_label(value) ⇒ Allure::Label

Test case label

Parameters:

  • value (String)

Returns:


102
103
104
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 102

def test_class_label(value)
  Label.new(TEST_CLASS_LABEL_NAME, value)
end

.thread_labelAllure::Label

Current thread label

Returns:


39
40
41
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 39

def thread_label
  Label.new(THREAD_LABEL_NAME, Thread.current.object_id)
end

.timestamp(time = nil) ⇒ Number

Parameters:

  • time (Time) (defaults to: nil)

Returns:

  • (Number)

33
34
35
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 33

def timestamp(time = nil)
  ((time || Time.now).to_f * 1000).to_i
end

TMS link

Parameters:

  • value (String)

Returns:


123
124
125
# File 'allure-ruby-commons/lib/allure_ruby_commons/result_utils.rb', line 123

def tms_link(value)
  Link.new(TMS_LINK_TYPE, value, tms_url(value))
end