allure-ruby-commons 2.13.8 → 2.13.8.5

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: af257eec6eec65a050aaff6d72cf0876bc522e984d9575d743c150bd51ef0fb6
4
- data.tar.gz: 9926ed3f22ce88e3ff6fdf8c2b26029101764a274824eccc5fca1cc2a8f1198e
3
+ metadata.gz: 0af09f2a82010cd21b1a58513757b558ec1ed18f60149fa98f27582a90f1282d
4
+ data.tar.gz: c8bfbc4769b01c79b78f44ded358b05ffa9bd53be814c47fa50c7f0e6f4dd9b4
5
5
  SHA512:
6
- metadata.gz: c616353fd1c76cf64f6ff6969ec35101714626a09f45515a2ef9a785858e876c6cc518f863dd8f97b690357f6f1fff7c95352369c6d446ae0ada67c23bceda65
7
- data.tar.gz: 13038ef5c8c8d8dedee56a3b3cbacbaf58056c4621ade1e53eb2ba4e2a821157f9f0dc400d546094e932b65afd4e369c152a4f62174ac28cc050f48d0b3e2f96
6
+ metadata.gz: 38e8563e40e3dcd96705e3a09cacfc561043e880abfad723ee5a482e133afde13e466d134d455bfd2549dbcb947599a1ab733fefe34d768c0aaa5fb5b8089cf7
7
+ data.tar.gz: 0ae240dad3392284b54ef54d3f22abed78763c39d71a88c60382af9324c79ea28438af40cb2c08e888e973f0cf22fb3961da4f9cff1eba0018bb510b8c7140e1
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:
@@ -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 [void]
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)
@@ -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.8
4
+ version: 2.13.8.5
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-12-17 00:00:00.000000000 Z
11
+ date: 2021-03-14 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.1.4
146
+ rubygems_version: 3.2.3
146
147
  signing_key:
147
148
  specification_version: 4
148
149
  summary: Common library for allure results generation