allure-ruby-commons 2.13.7 → 2.13.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/allure-ruby-commons.rb +12 -3
- data/lib/allure_ruby_commons/config.rb +1 -5
- data/lib/allure_ruby_commons/result_utils.rb +14 -7
- data/lib/allure_ruby_commons/step_annotation.rb +39 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7da435fb2a8bc93044eda5e385ae89ac30cc0ab26d4d64320de8248960de4e8
|
4
|
+
data.tar.gz: 463bb17a0bdfab7ba1660d91fcb6325d55b51da6314c47930aa39a7cbca46eb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b93cd5b075df1a25b7b9991b46fbf7deb83f4a99463742802d35d3456daae237f75ce169724910254a2815249677ab1716209f30077749a081958b0f895c02a
|
7
|
+
data.tar.gz: c91f38b4fe96d8e1a39a0c99a02e3d7a928f6aaec8ccc9f4e2109b7a099a4befc683f9c24d9dcbb0765e6b3d910d91e38bcd75674774617d27f85b880994835b
|
data/README.md
CHANGED
@@ -54,6 +54,23 @@ Allure.add_attachment(name: "attachment", source: "/path/to/test.txt", type: All
|
|
54
54
|
Allure.add_link(name: "Custom Url", url: "http://www.github.com")
|
55
55
|
```
|
56
56
|
|
57
|
+
## Steps
|
58
|
+
|
59
|
+
It is possible to mark method definitions to be automatically added to report as steps. The class just needs to extend `AllureStepAnnotation`
|
60
|
+
and `step` method needs to be used before the method definition.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
class TestHelper
|
64
|
+
extend AllureStepAnnotation
|
65
|
+
|
66
|
+
step("Singleton step")
|
67
|
+
def self.class_method; end
|
68
|
+
|
69
|
+
step("Standard step")
|
70
|
+
def standard_method; end
|
71
|
+
end
|
72
|
+
```
|
73
|
+
|
57
74
|
## Testing
|
58
75
|
|
59
76
|
Install dependencies:
|
data/lib/allure-ruby-commons.rb
CHANGED
@@ -64,6 +64,13 @@ module Allure
|
|
64
64
|
label(ResultUtils::SUITE_LABEL_NAME, value)
|
65
65
|
end
|
66
66
|
|
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
|
73
|
+
|
67
74
|
# Add label to current test case
|
68
75
|
# @param [String] name
|
69
76
|
# @param [String] value
|
@@ -162,14 +169,16 @@ module Allure
|
|
162
169
|
lifecycle.stop_test_step
|
163
170
|
end
|
164
171
|
|
165
|
-
# Run passed block as step with given name
|
172
|
+
# Run passed block as step with given name and return result of yield
|
166
173
|
# @param [String] name
|
167
174
|
# @yield [] step block
|
168
|
-
# @return [
|
175
|
+
# @return [Object]
|
169
176
|
def run_step(name)
|
170
177
|
lifecycle.start_test_step(StepResult.new(name: name, stage: Stage::RUNNING))
|
171
|
-
yield
|
178
|
+
result = yield
|
172
179
|
lifecycle.update_test_step { |step| step.status = Status::PASSED }
|
180
|
+
|
181
|
+
result
|
173
182
|
rescue StandardError => e
|
174
183
|
lifecycle.update_test_step do |step|
|
175
184
|
step.status = ResultUtils.status(e)
|
@@ -12,8 +12,6 @@ module Allure
|
|
12
12
|
LOGLEVELS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN].freeze
|
13
13
|
# @return [String] test plan path env var name
|
14
14
|
TESTPLAN_PATH = "ALLURE_TESTPLAN_PATH"
|
15
|
-
# @return [String] test plan file name
|
16
|
-
TESTPLAN_JSON = "testplan.json"
|
17
15
|
|
18
16
|
attr_accessor :results_directory, :logging_level, :link_tms_pattern, :link_issue_pattern, :clean_results_directory
|
19
17
|
|
@@ -43,9 +41,7 @@ module Allure
|
|
43
41
|
# @return [Array<Hash>]
|
44
42
|
def tests
|
45
43
|
@tests ||= begin
|
46
|
-
|
47
|
-
|
48
|
-
Oj.load_file("#{ENV[TESTPLAN_PATH]}/#{TESTPLAN_JSON}", symbol_keys: true)&.fetch(:tests)
|
44
|
+
Oj.load_file(ENV[TESTPLAN_PATH], symbol_keys: true)&.fetch(:tests) if ENV[TESTPLAN_PATH]
|
49
45
|
end
|
50
46
|
rescue Oj::ParseError
|
51
47
|
nil
|
@@ -59,6 +59,13 @@ module Allure
|
|
59
59
|
Label.new(FRAMEWORK_LABEL_NAME, value)
|
60
60
|
end
|
61
61
|
|
62
|
+
# Epic label
|
63
|
+
# @param [String] value
|
64
|
+
# @return [Allure::Label]
|
65
|
+
def epic_label(value)
|
66
|
+
Label.new(EPIC_LABEL_NAME, value)
|
67
|
+
end
|
68
|
+
|
62
69
|
# Feature label
|
63
70
|
# @param [String] value
|
64
71
|
# @return [Allure::Label]
|
@@ -66,6 +73,13 @@ module Allure
|
|
66
73
|
Label.new(FEATURE_LABEL_NAME, value)
|
67
74
|
end
|
68
75
|
|
76
|
+
# Story label
|
77
|
+
# @param [String] value
|
78
|
+
# @return [Allure::Label]
|
79
|
+
def story_label(value)
|
80
|
+
Label.new(STORY_LABEL_NAME, value)
|
81
|
+
end
|
82
|
+
|
69
83
|
# Package label
|
70
84
|
# @param [String] value
|
71
85
|
# @return [Allure::Label]
|
@@ -94,13 +108,6 @@ module Allure
|
|
94
108
|
Label.new(SUB_SUITE_LABEL_NAME, value)
|
95
109
|
end
|
96
110
|
|
97
|
-
# Story label
|
98
|
-
# @param [String] value
|
99
|
-
# @return [Allure::Label]
|
100
|
-
def story_label(value)
|
101
|
-
Label.new(STORY_LABEL_NAME, value)
|
102
|
-
end
|
103
|
-
|
104
111
|
# Test case label
|
105
112
|
# @param [String] value
|
106
113
|
# @return [Allure::Label]
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Adds support for annotating methods as allure steps
|
4
|
+
#
|
5
|
+
module AllureStepAnnotation
|
6
|
+
# Mark method definition as allure step
|
7
|
+
#
|
8
|
+
# @param [String] step_name
|
9
|
+
# @return [void]
|
10
|
+
def step(step_name = "")
|
11
|
+
@allure_step = step_name
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def singleton_method_added(method_name)
|
17
|
+
return super unless @allure_step
|
18
|
+
|
19
|
+
original_method = singleton_method(method_name)
|
20
|
+
step_name = @allure_step.empty? ? method_name.to_s : @allure_step
|
21
|
+
@allure_step = nil
|
22
|
+
|
23
|
+
define_singleton_method(method_name) do |*args, &block|
|
24
|
+
Allure.run_step(step_name) { original_method.call(*args, &block) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def method_added(method_name)
|
29
|
+
return super unless @allure_step
|
30
|
+
|
31
|
+
original_method = instance_method(method_name)
|
32
|
+
step_name = @allure_step.empty? ? method_name.to_s : @allure_step
|
33
|
+
@allure_step = nil
|
34
|
+
|
35
|
+
define_method(method_name) do |*args, &block|
|
36
|
+
Allure.run_step(step_name) { original_method.bind(self).call(*args, &block) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
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.
|
4
|
+
version: 2.13.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrejs Cunskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/allure_ruby_commons/model/test_result.rb
|
119
119
|
- lib/allure_ruby_commons/model/test_result_container.rb
|
120
120
|
- lib/allure_ruby_commons/result_utils.rb
|
121
|
+
- lib/allure_ruby_commons/step_annotation.rb
|
121
122
|
homepage: https://github.com/allure-framework/allure-ruby
|
122
123
|
licenses:
|
123
124
|
- Apache-2.0
|
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
143
|
- !ruby/object:Gem::Version
|
143
144
|
version: '0'
|
144
145
|
requirements: []
|
145
|
-
rubygems_version: 3.
|
146
|
+
rubygems_version: 3.2.3
|
146
147
|
signing_key:
|
147
148
|
specification_version: 4
|
148
149
|
summary: Common library for allure results generation
|