allure-ruby-commons 2.13.9 → 2.14.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00eb4480e678a3ec0c1f8d8e0b0885481f5be98bd0c0f4894a3665135769a7e6
4
- data.tar.gz: 1763a8e08847c62bf347600cb0d2f77cd8ff324d8a90771e5ba6011b321421ff
3
+ metadata.gz: 167b883e345ddf9b55cf96986f203371ea865bc470212f578e906989d10d3ea0
4
+ data.tar.gz: a7568ffb62caa98ac0e74c836630493b5ae228d2e4ff7ed7707be0862b4b012b
5
5
  SHA512:
6
- metadata.gz: fd6b37bea5da7b710428231f83efeff7d9bbaf7f17fbfd2575446f43a4db2237fad3fea012b585b4648007dcfa7120012e09e918b8d1457ad29ca63e2aac0bcb
7
- data.tar.gz: a9b335d4a796fcfade19f86272a3e9538fb9e5b0531fc8651a28b316b9e6ff4b2f1d9c535360ff065da2655869343950c5128a141cb69ed047d6413a8f315b11
6
+ metadata.gz: 974f8f097b193e9abfa0f17c1dadbcf4592f87734512a579540389982e5c05d3ef9bc68b22f5971c479a3279044195b46cce3b20ad010275b900d5a5c7919ae9
7
+ data.tar.gz: 36ffc3d9a9c9dfdc4ba4f03699fdb49d74e2db4f076404c698170dd0d95384876930c3150a39fe5381b7ea6d82dc692d9d451199194d4d808ef6084a97d76f55
data/README.md CHANGED
@@ -20,12 +20,23 @@ Following configuration options are supported:
20
20
 
21
21
  ```ruby
22
22
  Allure.configure do |config|
23
- config.results_directory = "/whatever/you/like"
23
+ config.results_directory = "report/allure-results"
24
24
  config.clean_results_directory = true
25
25
  config.logging_level = Logger::INFO
26
+ config.logger = Logger.new($stdout, Logger::DEBUG)
27
+ config.environment = "staging"
28
+
26
29
  # these are used for creating links to bugs or test cases where {} is replaced with keys of relevant items
27
30
  config.link_tms_pattern = "http://www.jira.com/browse/{}"
28
31
  config.link_issue_pattern = "http://www.jira.com/browse/{}"
32
+
33
+ # additional metadata
34
+ # environment.properties
35
+ config.environment_properties = {
36
+ custom_attribute: "foo"
37
+ }
38
+ # categories.json
39
+ config.categories = File.new("my_custom_categories.json")
29
40
  end
30
41
  ```
31
42
 
@@ -35,6 +46,13 @@ Getting the configuration object:
35
46
  Allure.configuration
36
47
  ```
37
48
 
49
+ ### Allure execution environment
50
+
51
+ It is possible to set up custom allure environment which will be used as custom parameter `environment` in every test case. This is useful if you run same tests on different environments and generate single report. This way different runs are not put as retry. Environment can be configured in following ways:
52
+
53
+ * via `ALLURE_ENVIRONMENT` environment variable
54
+ * via `configure` method
55
+
38
56
  ### Log level
39
57
 
40
58
  Log level can be also configured via environment variable `ALLURE_LOG_LEVEL` which accepts one of the following values: `DEBUG INFO WARN ERROR FATAL UNKNOWN`.
@@ -8,186 +8,204 @@ require_rel "allure_ruby_commons/**/*rb"
8
8
 
9
9
  # Namespace for classes that handle allure report generation and different framework adaptors
10
10
  module Allure
11
- class << self
12
- # Get thread specific allure lifecycle object
13
- # @return [AllureLifecycle]
14
- def lifecycle
15
- Thread.current[:lifecycle] ||= AllureLifecycle.new
16
- end
11
+ # Set lifecycle object
12
+ # @param [AllureLifecycle] lifecycle
13
+ # @return [void]
14
+ def self.lifecycle=(lifecycle)
15
+ Thread.current[:lifecycle] = lifecycle
16
+ end
17
17
 
18
- # Set lifecycle object
19
- # @param [AllureLifecycle] lifecycle
20
- # @return [void]
21
- def lifecycle=(lifecycle)
22
- Thread.current[:lifecycle] = lifecycle
23
- end
18
+ extend self # rubocop:disable Style/ModuleFunction
24
19
 
25
- # Get allure configuration
26
- # @return [Config]
27
- def configuration
28
- Config.instance
29
- end
20
+ # Get thread specific allure lifecycle object
21
+ # @return [AllureLifecycle]
22
+ def lifecycle
23
+ Thread.current[:lifecycle] ||= AllureLifecycle.new
24
+ end
30
25
 
31
- # Set allure configuration
32
- # @yieldparam [Config]
33
- # @yieldreturn [void]
34
- # @return [void]
35
- def configure
36
- yield(configuration)
37
- end
26
+ # Get allure configuration
27
+ # @return [Config]
28
+ def configuration
29
+ Config.instance
30
+ end
38
31
 
39
- # Add epic to current test case
40
- # @param [String] value
41
- # @return [void]
42
- def epic(value)
43
- label(ResultUtils::EPIC_LABEL_NAME, value)
44
- end
32
+ # Set allure configuration
33
+ # @yieldparam [Config]
34
+ # @yieldreturn [void]
35
+ # @return [void]
36
+ def configure
37
+ yield(configuration)
38
+ end
45
39
 
46
- # Add feature to current test case
47
- # @param [String] value
48
- # @return [void]
49
- def feature(value)
50
- label(ResultUtils::FEATURE_LABEL_NAME, value)
51
- end
40
+ # Add epic to current test case
41
+ # @param [String] value
42
+ # @return [void]
43
+ def epic(value)
44
+ replace_label(ResultUtils::EPIC_LABEL_NAME, value)
45
+ end
52
46
 
53
- # Add story to current test case
54
- # @param [String] value
55
- # @return [void]
56
- def story(value)
57
- label(ResultUtils::STORY_LABEL_NAME, value)
58
- end
47
+ # Add feature to current test case
48
+ # @param [String] value
49
+ # @return [void]
50
+ def feature(value)
51
+ replace_label(ResultUtils::FEATURE_LABEL_NAME, value)
52
+ end
59
53
 
60
- # Add suite to current test case
61
- # @param [String] value
62
- # @return [void]
63
- def suite(value)
64
- label(ResultUtils::SUITE_LABEL_NAME, value)
65
- end
54
+ # Add story to current test case
55
+ # @param [String] value
56
+ # @return [void]
57
+ def story(value)
58
+ replace_label(ResultUtils::STORY_LABEL_NAME, value)
59
+ end
66
60
 
67
- # Add tag to current test case
68
- # @param [String] value
69
- # @return [void]
70
- def tag(value)
71
- label(ResultUtils::TAG_LABEL_NAME, value)
72
- end
61
+ # Add suite to current test case
62
+ # @param [String] value
63
+ # @return [void]
64
+ def suite(value)
65
+ replace_label(ResultUtils::SUITE_LABEL_NAME, value)
66
+ end
73
67
 
74
- # Add label to current test case
75
- # @param [String] name
76
- # @param [String] value
77
- # @return [void]
78
- def label(name, value)
79
- lifecycle.update_test_case do |test_case|
80
- test_case.labels.push(Label.new(name, value))
81
- end
82
- end
68
+ # Add tag to current test case
69
+ # @param [String] value
70
+ # @return [void]
71
+ def tag(value)
72
+ label(ResultUtils::TAG_LABEL_NAME, value)
73
+ end
83
74
 
84
- # Add description to current test case
85
- # @param [String] description
86
- # @return [void]
87
- def add_description(description)
88
- lifecycle.update_test_case do |test_case|
89
- test_case.description = description
90
- end
75
+ # Add label to current test case
76
+ # @param [String] name
77
+ # @param [String] value
78
+ # @return [void]
79
+ def label(name, value)
80
+ lifecycle.update_test_case do |test_case|
81
+ test_case.labels.push(Label.new(name, value))
91
82
  end
83
+ end
92
84
 
93
- # Add html description to current test case
94
- # @param [String] description_html
95
- # @return [void]
96
- def description_html(description_html)
97
- lifecycle.update_test_case do |test_case|
98
- test_case.description_html = description_html
99
- end
100
- end
85
+ # Replace label in current test case
86
+ #
87
+ # @param [String] name
88
+ # @param [String] value
89
+ # @return [void]
90
+ def replace_label(name, value)
91
+ lifecycle.update_test_case do |test_case|
92
+ present = test_case.labels.detect { |l| l.name == name }
93
+ return label(name, value) unless present
101
94
 
102
- # Add parameter to current test case
103
- # @param [String] name
104
- # @param [String] value
105
- # @return [void]
106
- def parameter(name, value)
107
- lifecycle.update_test_case do |test_case|
108
- test_case.parameters.push(Parameter.new(name, value))
109
- end
95
+ test_case.labels.map! { |l| l.name == name ? Label.new(name, value) : l }
110
96
  end
97
+ end
111
98
 
112
- # Add tms link to current test case
113
- # @param [String] name
114
- # @param [String] url
115
- # @return [void]
116
- def tms(name, url)
117
- add_link(name: name, url: url, type: ResultUtils::TMS_LINK_TYPE)
99
+ # Add description to current test case
100
+ # @param [String] description
101
+ # @return [void]
102
+ def add_description(description)
103
+ lifecycle.update_test_case do |test_case|
104
+ test_case.description = description
118
105
  end
106
+ end
119
107
 
120
- # Add issue linkt to current test case
121
- # @param [String] name
122
- # @param [String] url
123
- # @return [void]
124
- def issue(name, url)
125
- add_link(name: name, url: url, type: ResultUtils::ISSUE_LINK_TYPE)
108
+ # Add html description to current test case
109
+ # @param [String] description_html
110
+ # @return [void]
111
+ def description_html(description_html)
112
+ lifecycle.update_test_case do |test_case|
113
+ test_case.description_html = description_html
126
114
  end
115
+ end
127
116
 
128
- # Add link to current test case
129
- # @param [String ] url
130
- # @param [String] name
131
- # @param [String] type type of the link used to display link icon
132
- # @return [void]
133
- def add_link(url:, name: nil, type: "custom")
134
- lifecycle.update_test_case do |test_case|
135
- test_case.links.push(Link.new(type, name || url, url))
136
- end
117
+ # Add parameter to current test case
118
+ # @param [String] name
119
+ # @param [String] value
120
+ # @return [void]
121
+ def parameter(name, value)
122
+ lifecycle.update_test_case do |test_case|
123
+ test_case.parameters.push(Parameter.new(name, value))
137
124
  end
125
+ end
138
126
 
139
- # Add attachment to current test case or step
140
- # @param [String] name Attachment name
141
- # @param [File, String] source File or string to save as attachment
142
- # @param [String] type attachment type defined in {ContentType} or any other valid mime type
143
- # @param [Boolean] test_case add attachment to current test case instead of test step
144
- # @return [void]
145
- def add_attachment(name:, source:, type:, test_case: false)
146
- lifecycle.add_attachment(name: name, source: source, type: type, test_case: test_case)
147
- end
127
+ # Add tms link to current test case
128
+ # @param [String] name
129
+ # @param [String] url
130
+ # @return [void]
131
+ def tms(name, url)
132
+ add_link(name: name, url: url, type: ResultUtils::TMS_LINK_TYPE)
133
+ end
148
134
 
149
- # Add allure report environment info
150
- # @param [Hash<Symbol, String>] environment
151
- # @return [void]
152
- def add_environment(environment)
153
- lifecycle.write_environment(environment)
154
- end
135
+ # Add issue linkt to current test case
136
+ # @param [String] name
137
+ # @param [String] url
138
+ # @return [void]
139
+ def issue(name, url)
140
+ add_link(name: name, url: url, type: ResultUtils::ISSUE_LINK_TYPE)
141
+ end
155
142
 
156
- # Add categories info
157
- # @param [File, Array<Category>] categories
158
- # @return [void]
159
- def add_categories(categories)
160
- lifecycle.write_categories(categories)
143
+ # Add link to current test case
144
+ # @param [String ] url
145
+ # @param [String] name
146
+ # @param [String] type type of the link used to display link icon
147
+ # @return [void]
148
+ def add_link(url:, name: nil, type: "custom")
149
+ lifecycle.update_test_case do |test_case|
150
+ test_case.links.push(Link.new(type, name || url, url))
161
151
  end
152
+ end
162
153
 
163
- # Add step with provided name and optional status to current test step, fixture or test case
164
- # @param [String] name
165
- # @param [Symbol] status {Status}, {Status::PASSED} by default
166
- # @return [void]
167
- def step(name:, status: nil)
168
- lifecycle.add_test_step(StepResult.new(name: name, status: status || Status::PASSED, stage: Stage::FINISHED))
169
- lifecycle.stop_test_step
170
- end
154
+ # Add attachment to current test case or step
155
+ # @param [String] name Attachment name
156
+ # @param [File, String] source File or string to save as attachment
157
+ # @param [String] type attachment type defined in {ContentType} or any other valid mime type
158
+ # @param [Boolean] test_case add attachment to current test case instead of test step
159
+ # @return [void]
160
+ def add_attachment(name:, source:, type:, test_case: false)
161
+ lifecycle.add_attachment(name: name, source: source, type: type, test_case: test_case)
162
+ end
171
163
 
172
- # Run passed block as step with given name and return result of yield
173
- # @param [String] name
174
- # @yield [] step block
175
- # @return [Object]
176
- def run_step(name)
177
- lifecycle.start_test_step(StepResult.new(name: name, stage: Stage::RUNNING))
178
- result = yield
179
- lifecycle.update_test_step { |step| step.status = Status::PASSED }
180
-
181
- result
182
- rescue StandardError => e
183
- lifecycle.update_test_step do |step|
184
- step.status = ResultUtils.status(e)
185
- step.status_details = ResultUtils.status_details(e)
186
- end
187
- raise(e)
188
- ensure
189
- lifecycle.stop_test_step
190
- end
164
+ # Manually create environment.properties file
165
+ # if this method is called before test run started and
166
+ # option clean_results_directory is enabled, the file will be deleted
167
+ # @param [Hash<Symbol, String>] environment
168
+ # @return [void]
169
+ def add_environment(environment)
170
+ lifecycle.write_environment(environment)
171
+ end
172
+
173
+ # Manually create categories.json file
174
+ # if this method is called before test run started and
175
+ # option clean_results_directory is enabled, the file will be deleted
176
+ # @param [File, Array<Category>] categories
177
+ # @return [void]
178
+ def add_categories(categories)
179
+ lifecycle.write_categories(categories)
180
+ end
181
+
182
+ # Add step with provided name and optional status to current test step, fixture or test case
183
+ # @param [String] name
184
+ # @param [Symbol] status {Status}, {Status::PASSED} by default
185
+ # @return [void]
186
+ def step(name:, status: nil)
187
+ lifecycle.add_test_step(StepResult.new(name: name, status: status || Status::PASSED, stage: Stage::FINISHED))
188
+ lifecycle.stop_test_step
189
+ end
190
+
191
+ # Run passed block as step with given name and return result of yield
192
+ # @param [String] name
193
+ # @yield [] step block
194
+ # @return [Object]
195
+ def run_step(name)
196
+ lifecycle.start_test_step(StepResult.new(name: name, stage: Stage::RUNNING))
197
+ result = yield
198
+ lifecycle.update_test_step { |step| step.status = Status::PASSED }
199
+
200
+ result
201
+ rescue StandardError => e
202
+ lifecycle.update_test_step do |step|
203
+ step.status = ResultUtils.status(e)
204
+ step.status_details = ResultUtils.status_details(e)
205
+ end
206
+ raise(e)
207
+ ensure
208
+ lifecycle.stop_test_step
191
209
  end
192
210
  end
193
211
  # rubocop:enable Naming/FileName
@@ -8,14 +8,20 @@ module Allure
8
8
  class AllureLifecycle # rubocop:disable Metrics/ClassLength
9
9
  extend Forwardable
10
10
 
11
- def initialize
11
+ # Allure lifecycle instance
12
+ #
13
+ # @param [Allure::Config] configuration
14
+ def initialize(config = Config.instance)
12
15
  @test_context = []
13
16
  @step_context = []
14
- @logger = Logger.new($stdout, level: Config.instance.logging_level)
15
- @file_writer = FileWriter.new
17
+ @config = config
18
+ @logger = config.logger
19
+ @file_writer = FileWriter.new(config.results_directory)
16
20
  end
17
21
 
18
- def_delegators :file_writer, :write_attachment, :write_environment, :write_categories
22
+ attr_reader :config
23
+
24
+ def_delegators :file_writer, :write_attachment
19
25
 
20
26
  # Start test result container
21
27
  # @param [Allure::TestResultContainer] test_result_container
@@ -215,6 +221,26 @@ module Allure
215
221
  write_attachment(source, attachment)
216
222
  end
217
223
 
224
+ # Add environment.properties file
225
+ #
226
+ # @param [Hash] env
227
+ # @return [void]
228
+ def write_environment(env = config.environment_properties)
229
+ return unless env
230
+
231
+ file_writer.write_environment(env)
232
+ end
233
+
234
+ # Add categories.json
235
+ #
236
+ # @param [File, Array<Category>] categories
237
+ # @return [void]
238
+ def write_categories(categories = config.categories)
239
+ return unless categories
240
+
241
+ file_writer.write_categories(categories)
242
+ end
243
+
218
244
  # Add step to current fixture|step|test case
219
245
  # @param [Allure::StepResult] step_result
220
246
  # @return [Allure::StepResult]
@@ -227,14 +253,12 @@ module Allure
227
253
  # Clean results directory
228
254
  # @return [void]
229
255
  def clean_results_dir
230
- Allure.configuration.tap do |c|
231
- FileUtils.rm_f(Dir.glob("#{c.results_directory}/**/*")) if c.clean_results_directory
232
- end
256
+ FileUtils.rm_f(Dir.glob("#{config.results_directory}/**/*")) if config.clean_results_directory
233
257
  end
234
258
 
235
259
  private
236
260
 
237
- attr_accessor :logger, :file_writer
261
+ attr_reader :logger, :file_writer
238
262
 
239
263
  def current_executable
240
264
  current_test_step || @current_fixture || @current_test_case
@@ -10,39 +10,36 @@ module Allure
10
10
 
11
11
  # @return [Array<String>] valid log levels
12
12
  LOGLEVELS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN].freeze
13
- # @return [String] test plan path env var name
14
- TESTPLAN_PATH = "ALLURE_TESTPLAN_PATH"
15
13
 
16
- attr_accessor :results_directory, :logging_level, :link_tms_pattern, :link_issue_pattern, :clean_results_directory
14
+ attr_writer :environment, :logger
15
+
16
+ attr_accessor :results_directory,
17
+ :logging_level,
18
+ :link_tms_pattern,
19
+ :link_issue_pattern,
20
+ :clean_results_directory,
21
+ :environment_properties,
22
+ :categories
17
23
 
18
24
  def initialize
19
25
  @results_directory = "reports/allure-results"
20
26
  @logging_level = LOGLEVELS.index(ENV.fetch("ALLURE_LOG_LEVEL", "INFO")) || Logger::INFO
21
27
  end
22
28
 
23
- # Allure id's of executable tests
29
+ # Allure environment
24
30
  #
25
- # @return [Array]
26
- def test_ids
27
- @test_ids ||= tests&.map { |test| test[:id] }
28
- end
31
+ # @return [String]
32
+ def environment
33
+ return(@environment) if defined?(@environment)
29
34
 
30
- # Test names of executable tests
31
- #
32
- # @return [Array]
33
- def test_names
34
- @test_names ||= tests&.map { |test| test[:selector] }
35
+ @environment ||= ENV["ALLURE_ENVIRONMENT"]
35
36
  end
36
37
 
37
- private
38
-
39
- # Tests to execute from allure testplan.json
38
+ # Logger instance
40
39
  #
41
- # @return [Array<Hash>]
42
- def tests
43
- @tests ||= Oj.load_file(ENV[TESTPLAN_PATH], symbol_keys: true)&.fetch(:tests) if ENV[TESTPLAN_PATH]
44
- rescue Oj::ParseError
45
- nil
40
+ # @return [Logger]
41
+ def logger
42
+ @logger ||= Logger.new($stdout, level: logging_level)
46
43
  end
47
44
  end
48
45
  end
@@ -14,6 +14,13 @@ module Allure
14
14
  # @return [String] categories definition json
15
15
  CATEGORIES_FILE = "categories.json"
16
16
 
17
+ # File writer instance
18
+ #
19
+ # @param [String] results_directory
20
+ def initialize(results_directory)
21
+ @results_directory = results_directory
22
+ end
23
+
17
24
  # Write test result
18
25
  # @param [Allure::TestResult] test_result
19
26
  # @return [void]
@@ -58,8 +65,10 @@ module Allure
58
65
 
59
66
  private
60
67
 
68
+ attr_reader :results_directory
69
+
61
70
  def output_dir
62
- @output_dir ||= FileUtils.mkpath(Config.instance.results_directory).first
71
+ @output_dir ||= FileUtils.mkpath(results_directory).first
63
72
  end
64
73
 
65
74
  def write(name, source)
@@ -24,12 +24,17 @@ module Allure
24
24
  @stage = options[:stage] || Stage::SCHEDULED
25
25
  @steps = options[:steps] || []
26
26
  @attachments = options[:attachments] || []
27
- @parameters = options[:parameters] || []
28
27
  end
29
28
 
30
- attr_accessor(
31
- :name, :status, :status_details, :stage, :description, :description_html,
32
- :steps, :attachments, :parameters, :start, :stop
33
- )
29
+ attr_accessor :name,
30
+ :status,
31
+ :status_details,
32
+ :stage,
33
+ :description,
34
+ :description_html,
35
+ :steps,
36
+ :attachments,
37
+ :start,
38
+ :stop
34
39
  end
35
40
  end
@@ -5,6 +5,7 @@ module Allure
5
5
  class TestResult < ExecutableItem
6
6
  # @param [String] uuid
7
7
  # @param [String] history_id
8
+ # @param [String] environment
8
9
  # @param [Hash] options
9
10
  # @option options [String] :name
10
11
  # @option options [String] :full_name
@@ -18,15 +19,36 @@ module Allure
18
19
  # @option options [Array<Allure::Link>] :links ([])
19
20
  # @option options [Array<Allure::Attachment>] :attachments ([])
20
21
  # @option options [Array<Allure::Parameter>] :parameters ([])
21
- def initialize(uuid: UUID.generate, history_id: UUID.generate, **options)
22
+ def initialize(uuid: UUID.generate, history_id: UUID.generate, environment: nil, **options)
22
23
  super
24
+
25
+ @name = options[:name]
23
26
  @uuid = uuid
24
- @history_id = history_id
27
+ @history_id = Digest::MD5.hexdigest("#{history_id}#{environment}")
25
28
  @full_name = options[:full_name] || "Unnamed"
26
29
  @labels = options[:labels] || []
27
30
  @links = options[:links] || []
31
+ @parameters = updated_parameters(options[:parameters] || [], environment)
28
32
  end
29
33
 
30
- attr_accessor :uuid, :history_id, :full_name, :labels, :links
34
+ attr_accessor :uuid,
35
+ :history_id,
36
+ :full_name,
37
+ :labels,
38
+ :links,
39
+ :parameters
40
+
41
+ private
42
+
43
+ # Test name prefixed with allure environment
44
+ #
45
+ # @param [Array] parameters
46
+ # @param [String] environment
47
+ # @return [Array]
48
+ def updated_parameters(parameters, environment)
49
+ return parameters unless environment
50
+
51
+ parameters << Parameter.new("environment", environment)
52
+ end
31
53
  end
32
54
  end
@@ -131,16 +131,18 @@ module Allure
131
131
 
132
132
  # TMS link
133
133
  # @param [String] value
134
+ # @param [String] link_pattern
134
135
  # @return [Allure::Link]
135
- def tms_link(value)
136
- Link.new(TMS_LINK_TYPE, value, tms_url(value))
136
+ def tms_link(value, link_pattern)
137
+ Link.new(TMS_LINK_TYPE, value, url(value, link_pattern))
137
138
  end
138
139
 
139
140
  # Issue link
140
141
  # @param [String] value
142
+ # @param [String] link_pattern
141
143
  # @return [Allure::Link]
142
- def issue_link(value)
143
- Link.new(ISSUE_LINK_TYPE, value, issue_url(value))
144
+ def issue_link(value, link_pattern)
145
+ Link.new(ISSUE_LINK_TYPE, value, url(value, link_pattern))
144
146
  end
145
147
 
146
148
  # Get status based on exception type
@@ -169,12 +171,8 @@ module Allure
169
171
 
170
172
  private
171
173
 
172
- def tms_url(value)
173
- Allure.configuration.link_tms_pattern.sub("{}", value)
174
- end
175
-
176
- def issue_url(value)
177
- Allure.configuration.link_issue_pattern.sub("{}", value)
174
+ def url(value, link_pattern)
175
+ link_pattern.sub("{}", value)
178
176
  end
179
177
  end
180
178
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Allure
4
+ class TestPlan
5
+ # @return [String] test plan path env var name
6
+ TESTPLAN_PATH = "ALLURE_TESTPLAN_PATH"
7
+
8
+ class << self
9
+ # Allure id's of executable tests
10
+ #
11
+ # @return [Array]
12
+ def test_ids
13
+ @test_ids ||= tests&.map { |test| test[:id] }
14
+ end
15
+
16
+ # Test names of executable tests
17
+ #
18
+ # @return [Array]
19
+ def test_names
20
+ @test_names ||= tests&.map { |test| test[:selector] }
21
+ end
22
+
23
+ private
24
+
25
+ # Tests to execute from allure testplan.json
26
+ #
27
+ # @return [Array<Hash>]
28
+ def tests
29
+ @tests ||= Oj.load_file(ENV[TESTPLAN_PATH], symbol_keys: true)&.fetch(:tests) if ENV[TESTPLAN_PATH]
30
+ rescue Oj::ParseError
31
+ nil
32
+ end
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-ruby-commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.9
4
+ version: 2.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-15 00:00:00.000000000 Z
11
+ date: 2021-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -119,6 +119,7 @@ files:
119
119
  - lib/allure_ruby_commons/model/test_result_container.rb
120
120
  - lib/allure_ruby_commons/result_utils.rb
121
121
  - lib/allure_ruby_commons/step_annotation.rb
122
+ - lib/allure_ruby_commons/testplan.rb
122
123
  homepage: https://github.com/allure-framework/allure-ruby
123
124
  licenses:
124
125
  - Apache-2.0
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
144
  - !ruby/object:Gem::Version
144
145
  version: '0'
145
146
  requirements: []
146
- rubygems_version: 3.2.15
147
+ rubygems_version: 3.2.22
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: Common library for allure results generation