allure-ruby-commons 2.13.5.rc.1 → 2.13.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -7
- data/lib/allure-ruby-commons.rb +9 -9
- data/lib/allure_ruby_commons/allure_lifecycle.rb +24 -14
- data/lib/allure_ruby_commons/config.rb +9 -14
- data/lib/allure_ruby_commons/file_writer.rb +6 -3
- data/lib/allure_ruby_commons/model/attachment.rb +2 -0
- data/lib/allure_ruby_commons/model/category.rb +2 -0
- data/lib/allure_ruby_commons/model/executable_item.rb +2 -0
- data/lib/allure_ruby_commons/model/jsonable.rb +3 -3
- data/lib/allure_ruby_commons/model/label.rb +2 -0
- data/lib/allure_ruby_commons/model/link.rb +2 -0
- data/lib/allure_ruby_commons/model/parameter.rb +2 -0
- data/lib/allure_ruby_commons/model/status_details.rb +2 -0
- data/lib/allure_ruby_commons/model/test_result_container.rb +2 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dde5d93b183282927b03e256e2d9cbe933fd234aa9230545b7d91f074111a20
|
4
|
+
data.tar.gz: 8c05594912decb62f1fc9cc52ebdc85ff9a506c6bd1cbb8cb0a71f7d54102dca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8feed62b8a1f8c1182566623ac01e35356f6ce43dc86479b76175ae0cee0480517df3f5bc349a624a8ae4769acc1e72e10ccde649fc204debe508dd8b104783
|
7
|
+
data.tar.gz: f58060aa2b39d17b5a28b7ae222c049d96d734a64ea238d27a2fa536fd4010015fe11c3abbd43cb6ce28ec1b7548dffa245dc7c75f1fdf622c1e0cb04a24551c
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ you can just create the report of any other kind using the basic Allure terms.
|
|
11
11
|
Add the dependency to your Gemfile
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem
|
14
|
+
gem "allure-ruby-commons"
|
15
15
|
```
|
16
16
|
|
17
17
|
## Configuration
|
@@ -19,13 +19,13 @@ Add the dependency to your Gemfile
|
|
19
19
|
Following configuration options are supported:
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
Allure.configure do |
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
Allure.configure do |config|
|
23
|
+
config.results_directory = "/whatever/you/like"
|
24
|
+
config.clean_results_directory = true
|
25
|
+
config.logging_level = Logger::INFO
|
26
26
|
# these are used for creating links to bugs or test cases where {} is replaced with keys of relevant items
|
27
|
-
|
28
|
-
|
27
|
+
config.link_tms_pattern = "http://www.jira.com/browse/{}"
|
28
|
+
config.link_issue_pattern = "http://www.jira.com/browse/{}"
|
29
29
|
end
|
30
30
|
```
|
31
31
|
|
@@ -35,6 +35,10 @@ Getting the configuration object:
|
|
35
35
|
Allure.configuration
|
36
36
|
```
|
37
37
|
|
38
|
+
### Log level
|
39
|
+
|
40
|
+
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`.
|
41
|
+
|
38
42
|
## Allure lifecycle
|
39
43
|
|
40
44
|
Reports are built using API defined in AllureLifecycle class and using allure specific entities defined in models.
|
data/lib/allure-ruby-commons.rb
CHANGED
@@ -9,30 +9,30 @@ require_rel "allure_ruby_commons/**/*rb"
|
|
9
9
|
module Allure
|
10
10
|
class << self
|
11
11
|
# Get thread specific allure lifecycle object
|
12
|
-
# @return [
|
12
|
+
# @return [AllureLifecycle]
|
13
13
|
def lifecycle
|
14
14
|
Thread.current[:lifecycle] ||= AllureLifecycle.new
|
15
15
|
end
|
16
16
|
|
17
17
|
# Set lifecycle object
|
18
|
-
# @param [
|
18
|
+
# @param [AllureLifecycle] lifecycle
|
19
19
|
# @return [void]
|
20
20
|
def lifecycle=(lifecycle)
|
21
21
|
Thread.current[:lifecycle] = lifecycle
|
22
22
|
end
|
23
23
|
|
24
24
|
# Get allure configuration
|
25
|
-
# @return [
|
25
|
+
# @return [Config]
|
26
26
|
def configuration
|
27
|
-
Config
|
27
|
+
Config.instance
|
28
28
|
end
|
29
29
|
|
30
30
|
# Set allure configuration
|
31
|
-
# @yieldparam [
|
31
|
+
# @yieldparam [Config]
|
32
32
|
# @yieldreturn [void]
|
33
33
|
# @return [void]
|
34
34
|
def configure
|
35
|
-
yield(
|
35
|
+
yield(configuration)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Add epic to current test case
|
@@ -131,7 +131,7 @@ module Allure
|
|
131
131
|
# Add attachment to current test case or step
|
132
132
|
# @param [String] name Attachment name
|
133
133
|
# @param [File, String] source File or string to save as attachment
|
134
|
-
# @param [String] type attachment type defined in {
|
134
|
+
# @param [String] type attachment type defined in {ContentType} or any other valid mime type
|
135
135
|
# @param [Boolean] test_case add attachment to current test case instead of test step
|
136
136
|
# @return [void]
|
137
137
|
def add_attachment(name:, source:, type:, test_case: false)
|
@@ -146,7 +146,7 @@ module Allure
|
|
146
146
|
end
|
147
147
|
|
148
148
|
# Add categories info
|
149
|
-
# @param [File, Array<
|
149
|
+
# @param [File, Array<Category>] categories
|
150
150
|
# @return [void]
|
151
151
|
def add_categories(categories)
|
152
152
|
lifecycle.write_categories(categories)
|
@@ -154,7 +154,7 @@ module Allure
|
|
154
154
|
|
155
155
|
# Add step with provided name and optional status to current test step, fixture or test case
|
156
156
|
# @param [String] name
|
157
|
-
# @param [Symbol] status
|
157
|
+
# @param [Symbol] status {Status}, {Status::PASSED} by default
|
158
158
|
# @return [void]
|
159
159
|
def step(name:, status: nil)
|
160
160
|
lifecycle.add_test_step(StepResult.new(name: name, status: status || Status::PASSED, stage: Stage::FINISHED))
|
@@ -11,7 +11,7 @@ module Allure
|
|
11
11
|
def initialize
|
12
12
|
@test_context = []
|
13
13
|
@step_context = []
|
14
|
-
@logger = Logger.new(STDOUT, level: Config.logging_level)
|
14
|
+
@logger = Logger.new(STDOUT, level: Config.instance.logging_level)
|
15
15
|
@file_writer = FileWriter.new
|
16
16
|
end
|
17
17
|
|
@@ -22,6 +22,8 @@ module Allure
|
|
22
22
|
# @return [Allure::TestResultContainer]
|
23
23
|
def start_test_container(test_result_container)
|
24
24
|
test_result_container.tap do |container|
|
25
|
+
logger.debug { "Starting test container: #{container.name}" }
|
26
|
+
|
25
27
|
container.start = ResultUtils.timestamp
|
26
28
|
@test_context.push(container)
|
27
29
|
end
|
@@ -36,7 +38,7 @@ module Allure
|
|
36
38
|
# @return [void]
|
37
39
|
def update_test_container
|
38
40
|
unless current_test_result_container
|
39
|
-
return logger.error
|
41
|
+
return logger.error { "Could not update test container, no container is running." }
|
40
42
|
end
|
41
43
|
|
42
44
|
yield(current_test_result_container)
|
@@ -46,10 +48,11 @@ module Allure
|
|
46
48
|
# @return [void]
|
47
49
|
def stop_test_container
|
48
50
|
unless current_test_result_container
|
49
|
-
return logger.error
|
51
|
+
return logger.error { "Could not stop test container, no container is running." }
|
50
52
|
end
|
51
53
|
|
52
54
|
current_test_result_container.tap do |container|
|
55
|
+
logger.debug { "Stopping container: #{container.name}" }
|
53
56
|
container.stop = ResultUtils.timestamp
|
54
57
|
file_writer.write_test_result_container(container)
|
55
58
|
clear_last_test_container
|
@@ -62,9 +65,10 @@ module Allure
|
|
62
65
|
def start_test_case(test_result)
|
63
66
|
clear_step_context
|
64
67
|
unless current_test_result_container
|
65
|
-
return logger.error
|
68
|
+
return logger.error { "Could not start test case, test container is not started" }
|
66
69
|
end
|
67
70
|
|
71
|
+
logger.debug("Starting test case: #{test_result.name}")
|
68
72
|
test_result.start = ResultUtils.timestamp
|
69
73
|
test_result.stage = Stage::RUNNING
|
70
74
|
test_result.labels.push(ResultUtils.thread_label, ResultUtils.host_label, ResultUtils.language_label)
|
@@ -80,7 +84,7 @@ module Allure
|
|
80
84
|
# @yieldreturn [void]
|
81
85
|
# @return [void]
|
82
86
|
def update_test_case
|
83
|
-
return logger.error
|
87
|
+
return logger.error { "Could not update test case, no test case running" } unless @current_test_case
|
84
88
|
|
85
89
|
yield(@current_test_case)
|
86
90
|
end
|
@@ -88,8 +92,9 @@ module Allure
|
|
88
92
|
# Stop current test case and write result
|
89
93
|
# @return [void]
|
90
94
|
def stop_test_case
|
91
|
-
return logger.error
|
95
|
+
return logger.error { "Could not stop test case, no test case is running" } unless @current_test_case
|
92
96
|
|
97
|
+
logger.debug { "Stopping test case: #{@current_test_case.name}" }
|
93
98
|
@current_test_case.stop = ResultUtils.timestamp
|
94
99
|
@current_test_case.stage = Stage::FINISHED
|
95
100
|
file_writer.write_test_result(@current_test_case)
|
@@ -101,8 +106,9 @@ module Allure
|
|
101
106
|
# @param [Allure::StepResult] step_result
|
102
107
|
# @return [Allure::StepResult]
|
103
108
|
def start_test_step(step_result)
|
104
|
-
return logger.error
|
109
|
+
return logger.error { "Could not start test step, no test case is running" } unless @current_test_case
|
105
110
|
|
111
|
+
logger.debug { "Starting test step: #{step_result.name}" }
|
106
112
|
step_result.start = ResultUtils.timestamp
|
107
113
|
step_result.stage = Stage::RUNNING
|
108
114
|
add_test_step(step_result)
|
@@ -117,7 +123,7 @@ module Allure
|
|
117
123
|
# @yieldreturn [void]
|
118
124
|
# @return [void]
|
119
125
|
def update_test_step
|
120
|
-
return logger.error
|
126
|
+
return logger.error { "Could not update test step, no step is running" } unless current_test_step
|
121
127
|
|
122
128
|
yield(current_test_step)
|
123
129
|
end
|
@@ -125,8 +131,9 @@ module Allure
|
|
125
131
|
# Stop current test step
|
126
132
|
# @return [void]
|
127
133
|
def stop_test_step
|
128
|
-
return logger.error
|
134
|
+
return logger.error { "Could not stop test step, no step is running" } unless current_test_step
|
129
135
|
|
136
|
+
logger.debug { "Stoping test step: #{current_test_step.stop}" }
|
130
137
|
current_test_step.stop = ResultUtils.timestamp
|
131
138
|
current_test_step.stage = Stage::FINISHED
|
132
139
|
clear_last_test_step
|
@@ -160,6 +167,7 @@ module Allure
|
|
160
167
|
return false
|
161
168
|
end
|
162
169
|
|
170
|
+
logger.debug { "Starting fixture: #{fixture_result.name}" }
|
163
171
|
fixture_result.start = ResultUtils.timestamp
|
164
172
|
fixture_result.stage = Stage::RUNNING
|
165
173
|
end
|
@@ -172,7 +180,7 @@ module Allure
|
|
172
180
|
# @yieldreturn [void]
|
173
181
|
# @return [void]
|
174
182
|
def update_fixture
|
175
|
-
return logger.error
|
183
|
+
return logger.error { "Could not update fixture, fixture is not started" } unless @current_fixture
|
176
184
|
|
177
185
|
yield(@current_fixture)
|
178
186
|
end
|
@@ -180,8 +188,9 @@ module Allure
|
|
180
188
|
# Stop current test fixture
|
181
189
|
# @return [void]
|
182
190
|
def stop_fixture
|
183
|
-
return logger.error
|
191
|
+
return logger.error { "Could not stop fixture, fixture is not started" } unless @current_fixture
|
184
192
|
|
193
|
+
logger.debug { "Stopping fixture: #{@current_fixture.name}" }
|
185
194
|
@current_fixture.stop = ResultUtils.timestamp
|
186
195
|
@current_fixture.stage = Stage::FINISHED
|
187
196
|
clear_current_fixture
|
@@ -196,12 +205,13 @@ module Allure
|
|
196
205
|
# @return [void]
|
197
206
|
def add_attachment(name:, source:, type:, test_case: false)
|
198
207
|
attachment = ResultUtils.prepare_attachment(name, type) || begin
|
199
|
-
return logger.error
|
208
|
+
return logger.error { "Can't add attachment, unrecognized mime type: #{type}" }
|
200
209
|
end
|
201
210
|
executable_item = (test_case && @current_test_case) || current_executable
|
202
211
|
executable_item&.attachments&.push(attachment) || begin
|
203
|
-
return logger.error
|
212
|
+
return logger.error { "Can't add attachment, no test, step or fixture is running" }
|
204
213
|
end
|
214
|
+
logger.debug { "Adding attachment '#{name}' to '#{executable_item.name}'" }
|
205
215
|
write_attachment(source, attachment)
|
206
216
|
end
|
207
217
|
|
@@ -218,7 +228,7 @@ module Allure
|
|
218
228
|
# @return [void]
|
219
229
|
def clean_results_dir
|
220
230
|
Allure.configuration.tap do |c|
|
221
|
-
FileUtils.rm_f(Dir.glob("#{c.results_directory}
|
231
|
+
FileUtils.rm_f(Dir.glob("#{c.results_directory}/**/*")) if c.clean_results_directory
|
222
232
|
end
|
223
233
|
end
|
224
234
|
|
@@ -1,26 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "logger"
|
4
|
+
require "singleton"
|
4
5
|
|
5
6
|
module Allure
|
6
7
|
# Allure configuration class
|
7
8
|
class Config
|
8
|
-
|
9
|
-
DEFAULT_RESULTS_DIRECTORY = "reports/allure-results"
|
10
|
-
# @return [String] default loggin level
|
11
|
-
DEFAULT_LOGGING_LEVEL = Logger::INFO
|
9
|
+
include Singleton
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
attr_writer :results_directory, :logging_level
|
11
|
+
# @return [Array<String>] valid log levels
|
12
|
+
LOGLEVELS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN].freeze
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def logging_level
|
22
|
-
@logging_level || DEFAULT_LOGGING_LEVEL
|
23
|
-
end
|
14
|
+
def initialize
|
15
|
+
@results_directory = "reports/allure-results"
|
16
|
+
@logging_level = LOGLEVELS.index(ENV.fetch("ALLURE_LOG_LEVEL", "INFO")) || Logger::INFO
|
24
17
|
end
|
18
|
+
|
19
|
+
attr_accessor :results_directory, :logging_level, :link_tms_pattern, :link_issue_pattern, :clean_results_directory
|
25
20
|
end
|
26
21
|
end
|
@@ -18,14 +18,17 @@ module Allure
|
|
18
18
|
# @param [Allure::TestResult] test_result
|
19
19
|
# @return [void]
|
20
20
|
def write_test_result(test_result)
|
21
|
-
write("#{test_result.uuid}#{TEST_RESULT_SUFFIX}", test_result
|
21
|
+
write("#{test_result.uuid}#{TEST_RESULT_SUFFIX}", JSON.generate(test_result, max_nesting: false))
|
22
22
|
end
|
23
23
|
|
24
24
|
# Write test result container
|
25
25
|
# @param [Allure::TestResultContainer] test_container_result
|
26
26
|
# @return [void]
|
27
27
|
def write_test_result_container(test_container_result)
|
28
|
-
write(
|
28
|
+
write(
|
29
|
+
"#{test_container_result.uuid}#{TEST_RESULT_CONTAINER_SUFFIX}",
|
30
|
+
JSON.generate(test_container_result, max_nesting: false),
|
31
|
+
)
|
29
32
|
end
|
30
33
|
|
31
34
|
# Write allure attachment file
|
@@ -59,7 +62,7 @@ module Allure
|
|
59
62
|
private
|
60
63
|
|
61
64
|
def output_dir
|
62
|
-
@output_dir ||= FileUtils.mkpath(
|
65
|
+
@output_dir ||= FileUtils.mkpath(Config.instance.results_directory).first
|
63
66
|
end
|
64
67
|
|
65
68
|
def write(name, source)
|
@@ -10,6 +10,8 @@ module Allure
|
|
10
10
|
# @param [String, Regexp] message_regex
|
11
11
|
# @param [String, Regexp] trace_regex
|
12
12
|
def initialize(name:, matched_statuses: nil, message_regex: nil, trace_regex: nil)
|
13
|
+
super()
|
14
|
+
|
13
15
|
@name = name
|
14
16
|
@matched_statuses = matched_statuses
|
15
17
|
@message_regex = message_regex
|
@@ -16,6 +16,8 @@ module Allure
|
|
16
16
|
# @option options [Array<Allure::Attachment>] :attachments ([])
|
17
17
|
# @option options [Array<Allure::Parameter>] :parameters ([])
|
18
18
|
def initialize(**options)
|
19
|
+
super()
|
20
|
+
|
19
21
|
@name = options[:name]
|
20
22
|
@description = options[:description]
|
21
23
|
@description_html = options[:description_html]
|
@@ -6,9 +6,9 @@ module Allure
|
|
6
6
|
# General jsonable object implementation
|
7
7
|
class JSONable
|
8
8
|
# Return object has represantation
|
9
|
-
# @param [
|
9
|
+
# @param [Array<Object>] _options
|
10
10
|
# @return [Hash]
|
11
|
-
def as_json(_options
|
11
|
+
def as_json(*_options)
|
12
12
|
instance_variables.each_with_object({}) do |var, map|
|
13
13
|
key = camelcase(var.to_s.delete_prefix("@"))
|
14
14
|
value = instance_variable_get(var)
|
@@ -20,7 +20,7 @@ module Allure
|
|
20
20
|
# @param [Array<Object>] options
|
21
21
|
# @return [String]
|
22
22
|
def to_json(*options)
|
23
|
-
as_json
|
23
|
+
as_json.to_json(*options)
|
24
24
|
end
|
25
25
|
|
26
26
|
# Object comparator
|
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.
|
4
|
+
version: 2.13.6.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: 2020-
|
11
|
+
date: 2020-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uuid
|
@@ -126,9 +126,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: 2.5.0
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubygems_version: 3.1.2
|
134
134
|
signing_key:
|