allure-cucumber 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: d7d77ff4a8eb6b33fe7fb6e8fb0fe43c30715e602748ab82045413db15e73205
4
- data.tar.gz: dfe08d10319023b251ee3fc7d9ed23c2b48c341122130e774e0a33a5f981ad6c
3
+ metadata.gz: 57a580b2688ec11e41f3f5908c951f6d31d5258687baf78f06f19dd49360ba36
4
+ data.tar.gz: 4c0d60f34cf3ad25a2b65b1149b347a569d8da0cf7b0923c90cec39cf4f75a04
5
5
  SHA512:
6
- metadata.gz: c39009ffb92212511a4b3a2e6f64ddb85eddfb357b7ef18a0e5757cdaa9b451574499379c823dfa23ad6c415bb10521b6156cb5b9e8c7b5f375dd7c912a15bcc
7
- data.tar.gz: 8ae456ea73dc7fd9f68bb379553b4b2e807db6ca932a13c35e109c9164b260fd0d39c71cfccf9c523a9aa0a531d89fc17c62bda7edc2d2ffc02cfd0bbc7c11ca
6
+ metadata.gz: f1aa240e8acab0e721c4347f31d7eebce0ef49ca5c1757bb3b55b896ee44ad89a9e164874cb2dc93d4114bf7880d3e4bd262bffb016c89d99d6ef48f30a2f00f
7
+ data.tar.gz: 5a9fb7d3c2c606368d8fb8028eb26a67942012375b725fc89d99836b0342e8230100d3feb9555ba1095f8feb8d4891a9d6fa8d516d0b3b4a6e14f8a772d2b75c
data/README.md CHANGED
@@ -52,18 +52,24 @@ AllureCucumber.configure do |config|
52
52
  end
53
53
  ```
54
54
 
55
- By default, allure-cucumber will analyze your cucumber tags looking for Test Management, Issue Management, and Severity tag. Links to TMS and ISSUE and test severity will be displayed in the report. By default these prefixes are used:
55
+ By default, allure-cucumber will analyze your cucumber tags looking for Test Management, Issue Management, and Severity tag as well
56
+ as custom tags for grouping tests in to epics, features and stories in Behavior tab of report. Links to TMS and ISSUE and test severity will be displayed in the report.
57
+
58
+ By default these prefixes are used:
56
59
 
57
60
  ```ruby
58
61
  DEFAULT_TMS_PREFIX = 'TMS:'
59
62
  DEFAULT_ISSUE_PREFIX = 'ISSUE:'
60
63
  DEFAULT_SEVERITY_PREFIX = 'SEVERITY:'
64
+ DEFAULT_EPIC_PREFIX = 'EPIC:'
65
+ DEFAULT_FEATURE_PREFIX = 'FEATURE:'
66
+ DEFAULT_STORY_PREFIX = 'STORY:'
61
67
  ```
62
68
 
63
69
  Example:
64
70
 
65
71
  ```gherkin
66
- @SEVERITY:trivial @ISSUE:YZZ-100 @TMS:9901
72
+ @SEVERITY:trivial @ISSUE:YZZ-100 @TMS:9901 @EPIC:custom-epic
67
73
  Scenario: Leave First Name Blank
68
74
  When I register an account without a first name
69
75
  Then exactly (1) [validation_error] should be visible
@@ -76,13 +82,16 @@ AllureCucumber.configure do |config|
76
82
  config.tms_prefix = 'HIPTEST--'
77
83
  config.issue_prefix = 'JIRA++'
78
84
  config.severity_prefix = 'URGENCY:'
85
+ config.epic_prefix = 'epic:'
86
+ config.feature_prefix = 'feature:'
87
+ config.story_prefix = 'story:'
79
88
  end
80
89
  ```
81
90
 
82
91
  Example:
83
92
 
84
93
  ```gherkin
85
- @URGENCY:critical @JIRA++YZZ-100 @HIPTEST--9901
94
+ @URGENCY:critical @JIRA++YZZ-100 @HIPTEST--9901 @epic:custom-epic
86
95
  Scenario: Leave First Name Blank
87
96
  When I register an account without a first name
88
97
  Then exactly (1) [validation_error] should be visible
@@ -105,6 +114,8 @@ Allure.add_attachment(name: "attachment", source: "Some string", type: Allure::C
105
114
  Allure.add_link("Custom Url", "http://www.github.com")
106
115
  ```
107
116
 
117
+ It's possible to mark methods so those are included as allure steps: [Step annotations](../allure-ruby-commons/README.md#steps)
118
+
108
119
  ### Example project
109
120
 
110
121
  [Cucumber Example](https://github.com/allure-examples/allure-cucumber-example)
@@ -3,8 +3,7 @@
3
3
 
4
4
  require "allure-ruby-commons"
5
5
 
6
- require "allure_cucumber/config"
7
- require "allure_cucumber/formatter"
6
+ require_rel "allure_cucumber"
8
7
 
9
8
  # Main allure-cucumber module providing configuration methods
10
9
  module AllureCucumber
@@ -15,6 +15,12 @@ module AllureCucumber
15
15
  DEFAULT_ISSUE_PREFIX = "ISSUE:"
16
16
  # @return [String] default severity tag prefix
17
17
  DEFAULT_SEVERITY_PREFIX = "SEVERITY:"
18
+ # @return [String] default epic tag prefix
19
+ DEFAULT_EPIC_PREFIX = "EPIC:"
20
+ # @return [String] default feature tag prefix
21
+ DEFAULT_FEATURE_PREFIX = "FEATURE:"
22
+ # @return [String] default story tag prefix
23
+ DEFAULT_STORY_PREFIX = "STORY:"
18
24
 
19
25
  def_delegators :@allure_config,
20
26
  :clean_results_directory,
@@ -50,5 +56,20 @@ module AllureCucumber
50
56
  def severity_prefix
51
57
  @severity_prefix || DEFAULT_SEVERITY_PREFIX
52
58
  end
59
+
60
+ # @return [String]
61
+ def epic_prefix
62
+ @epic_prefix || DEFAULT_EPIC_PREFIX
63
+ end
64
+
65
+ # @return [String]
66
+ def feature_prefix
67
+ @feature_prefix || DEFAULT_FEATURE_PREFIX
68
+ end
69
+
70
+ # @return [String]
71
+ def story_prefix
72
+ @story_prefix || DEFAULT_STORY_PREFIX
73
+ end
53
74
  end
54
75
  end
@@ -2,8 +2,6 @@
2
2
 
3
3
  require "cucumber/core"
4
4
 
5
- require_relative "models/cucumber_model"
6
-
7
5
  module AllureCucumber
8
6
  # Main formatter class. Translates cucumber event to allure lifecycle
9
7
  class CucumberFormatter
@@ -67,10 +65,8 @@ module AllureCucumber
67
65
  step.stage = Allure::Stage::FINISHED
68
66
  step.status = ALLURE_STATUS.fetch(event.result.to_sym, Allure::Status::BROKEN)
69
67
  end
70
- step_type = event.test_step.hook? ? "fixture" : "test_step"
71
68
 
72
- lifecycle.public_send("update_#{step_type}", &update_block)
73
- lifecycle.public_send("stop_#{step_type}")
69
+ event.test_step.hook? ? handle_hook_finished(event.test_step, update_block) : handle_step_finished(update_block)
74
70
  end
75
71
 
76
72
  # Handle test case finished event
@@ -100,6 +96,13 @@ module AllureCucumber
100
96
  Allure.lifecycle
101
97
  end
102
98
 
99
+ # Is hook fixture like Before, After or Step as AfterStep
100
+ # @param [String] text
101
+ # @return [boolean]
102
+ def fixture_hook?(text)
103
+ HOOK_HANDLERS.key?(text)
104
+ end
105
+
103
106
  # @param [Cucumber::Core::Test::Step] test_step
104
107
  # @return [void]
105
108
  def handle_step_started(test_step)
@@ -111,7 +114,27 @@ module AllureCucumber
111
114
  # @param [Cucumber::Core::Test::HookStep] hook_step
112
115
  # @return [void]
113
116
  def handle_hook_started(hook_step)
114
- lifecycle.public_send(HOOK_HANDLERS[hook_step.text], cucumber_model.fixture_result(hook_step))
117
+ result = cucumber_model.fixture_result(hook_step)
118
+ return lifecycle.start_test_step(result) unless fixture_hook?(hook_step.text)
119
+
120
+ lifecycle.public_send(HOOK_HANDLERS[hook_step.text], result)
121
+ end
122
+
123
+ # @param [Proc] update_block
124
+ # @return [void]
125
+ def handle_step_finished(update_block)
126
+ lifecycle.update_test_step(&update_block)
127
+ lifecycle.stop_test_step
128
+ end
129
+
130
+ # @param [Cucumber::Core::Test::HookStep] hook_step
131
+ # @param [Proc] update_block
132
+ # @return [void]
133
+ def handle_hook_finished(hook_step, update_block)
134
+ return handle_step_finished(update_block) unless fixture_hook?(hook_step.text)
135
+
136
+ lifecycle.update_fixture(&update_block)
137
+ lifecycle.stop_fixture
115
138
  end
116
139
  end
117
140
  end
@@ -4,15 +4,9 @@ require "csv"
4
4
  require "cucumber/core"
5
5
  require "cucumber/formatter/ast_lookup"
6
6
 
7
- require_relative "scenario"
8
- require_relative "step"
9
- require_relative "tag_parser"
10
-
11
7
  module AllureCucumber
12
8
  # Support class for transforming cucumber test entities in to allure model entities
13
9
  class AllureCucumberModel
14
- include TagParser
15
-
16
10
  # @param [Cucumber::Configuration] config
17
11
  def initialize(config)
18
12
  @ast_lookup = Cucumber::Formatter::AstLookup.new(config)
@@ -23,6 +17,7 @@ module AllureCucumber
23
17
  # @return [Allure::TestResult]
24
18
  def test_result(test_case)
25
19
  scenario = Scenario.new(test_case, ast_lookup)
20
+ parser = MetadataParser.new(scenario)
26
21
 
27
22
  Allure::TestResult.new(
28
23
  name: scenario.name,
@@ -30,10 +25,10 @@ module AllureCucumber
30
25
  description_html: scenario.description,
31
26
  history_id: scenario.id,
32
27
  full_name: scenario.name,
33
- labels: labels(scenario),
34
- links: links(scenario),
35
- parameters: parameters(scenario),
36
- status_details: Allure::StatusDetails.new(**status_detail_tags(scenario.tags))
28
+ labels: parser.labels,
29
+ links: parser.links,
30
+ parameters: parser.parameters,
31
+ status_details: parser.status_details
37
32
  )
38
33
  end
39
34
 
@@ -55,7 +50,7 @@ module AllureCucumber
55
50
  # @param [Cucumber::Core::Test::HookStep] hook_step
56
51
  # @return [Allure::StepResult]
57
52
  def fixture_result(hook_step)
58
- Allure::FixtureResult.new(name: hook_step.location.to_s.split("/").last)
53
+ Allure::FixtureResult.new(name: "#{hook_step.text} (#{hook_step.location.to_s.split('/').last})")
59
54
  end
60
55
 
61
56
  # Get failure details
@@ -72,36 +67,6 @@ module AllureCucumber
72
67
 
73
68
  attr_reader :ast_lookup, :lifecycle
74
69
 
75
- # @param [Scenario] scenario
76
- # @return [Array<Allure::Label>]
77
- def labels(scenario)
78
- labels = []
79
- labels << Allure::ResultUtils.framework_label("cucumber")
80
- labels << Allure::ResultUtils.feature_label(scenario.feature_name)
81
- labels << Allure::ResultUtils.package_label(scenario.feature_folder)
82
- labels << Allure::ResultUtils.suite_label(scenario.feature_name)
83
- labels << Allure::ResultUtils.story_label(scenario.name)
84
- labels << Allure::ResultUtils.test_class_label(scenario.feature_file_name)
85
- unless scenario.tags.empty?
86
- labels.push(*tag_labels(scenario.tags))
87
- labels << severity(scenario.tags)
88
- end
89
-
90
- labels
91
- end
92
-
93
- # @param [Cucumber::Core::Test::Case] test_case
94
- # @return [Array<Allure::Link>]
95
- def links(test_case)
96
- tms_links(test_case.tags) + issue_links(test_case.tags)
97
- end
98
-
99
- # @param [AllureCucumber::Scenario] scenario
100
- # @return [Array<Allure::Parameter>]
101
- def parameters(scenario)
102
- scenario.examples.map { |k, v| Allure::Parameter.new(k, v) }
103
- end
104
-
105
70
  # @param [Step] step
106
71
  # @return [Array<Allure::Attachment>]
107
72
  def step_attachments(step)
@@ -0,0 +1,137 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AllureCucumber
4
+ # Cucumber tag parser helper methods
5
+ class MetadataParser
6
+ def initialize(scenario)
7
+ @scenario = scenario
8
+ end
9
+
10
+ # @return [Array<Allure::Label>]
11
+ def labels
12
+ [
13
+ Allure::ResultUtils.framework_label("cucumber"),
14
+ Allure::ResultUtils.package_label(scenario.feature_folder),
15
+ Allure::ResultUtils.test_class_label(scenario.feature_file_name),
16
+ Allure::ResultUtils.suite_label(scenario.feature_name),
17
+ severity,
18
+ *behavior_labels,
19
+ *tag_labels
20
+ ].select(&:value)
21
+ end
22
+
23
+ # @return [Array<Allure::Label>]
24
+ def tag_labels
25
+ tags
26
+ .reject { |tag| reserved?(tag) }
27
+ .map { |tag| Allure::ResultUtils.tag_label(tag.delete_prefix("@")) }
28
+ end
29
+
30
+ # @param [Cucumber::Core::Test::Case] test_case
31
+ # @return [Array<Allure::Link>]
32
+ def links
33
+ tms_links + issue_links
34
+ end
35
+
36
+ # @return [Allure::Label]
37
+ def severity
38
+ Allure::ResultUtils.severity_label(tag_value(:severity) || "normal")
39
+ end
40
+
41
+ # @return [Array<Allure::Parameter>]
42
+ def parameters
43
+ scenario.examples.map { |k, v| Allure::Parameter.new(k, v) }
44
+ end
45
+
46
+ # @return [Hash<Symbol, Boolean>]
47
+ def status_details
48
+ Allure::StatusDetails.new(
49
+ flaky: tags.any? { |tag| tag.match?(reserved_patterns[:flaky]) },
50
+ muted: tags.any? { |tag| tag.match?(reserved_patterns[:muted]) },
51
+ known: tags.any? { |tag| tag.match?(reserved_patterns[:known]) }
52
+ )
53
+ end
54
+
55
+ # Get behavior labels
56
+ # @return [Array<Allure::Label>]
57
+ def behavior_labels
58
+ epic = tag_value(:epic) || scenario.feature_folder
59
+ feature = tag_value(:feature) || scenario.feature_name
60
+ story = tag_value(:story)
61
+
62
+ [
63
+ Allure::ResultUtils.epic_label(epic),
64
+ Allure::ResultUtils.feature_label(feature),
65
+ Allure::ResultUtils.story_label(story)
66
+ ]
67
+ end
68
+
69
+ private
70
+
71
+ # @return [AllureCucumber::Scenario]
72
+ attr_reader :scenario
73
+
74
+ # Get scenario tags
75
+ #
76
+ # @return [Array<String>]
77
+ def tags
78
+ @tags ||= scenario.tags
79
+ end
80
+
81
+ # @return [Array<Allure::Link>]
82
+ def tms_links
83
+ return [] unless AllureCucumber.configuration.link_tms_pattern
84
+
85
+ matching_links(:tms)
86
+ end
87
+
88
+ # @return [Array<Allure::Link>]
89
+ def issue_links
90
+ return [] unless AllureCucumber.configuration.link_issue_pattern
91
+
92
+ matching_links(:issue)
93
+ end
94
+
95
+ # @param [Symbol] type
96
+ # @return [Array<Allure::Link>]
97
+ def matching_links(type)
98
+ pattern = reserved_patterns[type]
99
+ tags
100
+ .select { |tag| tag.match?(pattern) }
101
+ .map { |tag| tag.match(pattern) { |match| Allure::ResultUtils.public_send("#{type}_link", match[type]) } }
102
+ end
103
+
104
+ # @return [Hash<Symbol, Regexp>]
105
+ def reserved_patterns
106
+ @reserved_patterns ||= {
107
+ tms: /@#{AllureCucumber.configuration.tms_prefix}(?<tms>\S+)/,
108
+ issue: /@#{AllureCucumber.configuration.issue_prefix}(?<issue>\S+)/,
109
+ severity: /@#{AllureCucumber.configuration.severity_prefix}(?<severity>\S+)/,
110
+ epic: /@#{AllureCucumber.configuration.epic_prefix}(?<epic>\S+)/,
111
+ feature: /@#{AllureCucumber.configuration.feature_prefix}(?<feature>\S+)/,
112
+ story: /@#{AllureCucumber.configuration.story_prefix}(?<story>\S+)/,
113
+ flaky: /@flaky/,
114
+ muted: /@muted/,
115
+ known: /@known/
116
+ }
117
+ end
118
+
119
+ # @param [String] tag
120
+ # @return [Boolean]
121
+ def reserved?(tag)
122
+ reserved_patterns.values.any? { |pattern| tag.match?(pattern) }
123
+ end
124
+
125
+ # Get specific tag value
126
+ #
127
+ # @param [Symbol] type
128
+ # @return [String]
129
+ def tag_value(type)
130
+ pattern = reserved_patterns[type]
131
+ tag = tags.detect { |t| t.match?(pattern) }
132
+ return unless tag
133
+
134
+ tag.match(pattern)[type]
135
+ end
136
+ end
137
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-cucumber
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: allure-ruby-commons
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.13.8
19
+ version: 2.13.8.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.13.8
26
+ version: 2.13.8.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: cucumber
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -55,9 +55,9 @@ files:
55
55
  - lib/allure_cucumber/config.rb
56
56
  - lib/allure_cucumber/formatter.rb
57
57
  - lib/allure_cucumber/models/cucumber_model.rb
58
+ - lib/allure_cucumber/models/metadata_parser.rb
58
59
  - lib/allure_cucumber/models/scenario.rb
59
60
  - lib/allure_cucumber/models/step.rb
60
- - lib/allure_cucumber/models/tag_parser.rb
61
61
  homepage: https://github.com/allure-framework/allure-ruby
62
62
  licenses:
63
63
  - Apache-2.0
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.1.4
85
+ rubygems_version: 3.2.3
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Allure cucumber ruby adaptor
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AllureCucumber
4
- # Cucumber tag parser helper methods
5
- module TagParser
6
- # @param [Array<String>] tags
7
- # @return [Array<Allure::Label>]
8
- def tag_labels(tags)
9
- tags
10
- .reject { |tag| reserved?(tag) }
11
- .map { |tag| Allure::ResultUtils.tag_label(tag.delete_prefix("@")) }
12
- end
13
-
14
- # @param [Array<String>] tags
15
- # @return [Array<Allure::Link>]
16
- def tms_links(tags)
17
- return [] unless AllureCucumber.configuration.link_tms_pattern
18
-
19
- matching_links(tags, :tms)
20
- end
21
-
22
- # @param [Array<String>] tags
23
- # @return [Array<Allure::Link>]
24
- def issue_links(tags)
25
- return [] unless AllureCucumber.configuration.link_issue_pattern
26
-
27
- matching_links(tags, :issue)
28
- end
29
-
30
- # @param [Array<String>] tags
31
- # @return [Allure::Label]
32
- def severity(tags)
33
- severity_pattern = reserved_patterns[:severity]
34
- severity_tags = tags.detect { |tag| tag.match?(severity_pattern) }
35
- severity = severity_tags&.match(severity_pattern)&.[](:severity) || "normal"
36
-
37
- Allure::ResultUtils.severity_label(severity)
38
- end
39
-
40
- # @param [Array<String>] tags
41
- # @return [Hash<Symbol, Boolean>]
42
- def status_detail_tags(tags)
43
- {
44
- flaky: tags.any? { |tag| tag.match?(reserved_patterns[:flaky]) },
45
- muted: tags.any? { |tag| tag.match?(reserved_patterns[:muted]) },
46
- known: tags.any? { |tag| tag.match?(reserved_patterns[:known]) }
47
- }
48
- end
49
-
50
- private
51
-
52
- # @param [Array<String>] tags
53
- # @param [Symbol] type
54
- # @return [Array<Allure::Link>]
55
- def matching_links(tags, type)
56
- pattern = reserved_patterns[type]
57
- tags
58
- .select { |tag| tag.match?(pattern) }
59
- .map { |tag| tag.match(pattern) { |match| Allure::ResultUtils.public_send("#{type}_link", match[type]) } }
60
- end
61
-
62
- # @return [Hash<Symbol, Regexp>]
63
- def reserved_patterns
64
- @reserved_patterns ||= {
65
- tms: /@#{AllureCucumber.configuration.tms_prefix}(?<tms>\S+)/,
66
- issue: /@#{AllureCucumber.configuration.issue_prefix}(?<issue>\S+)/,
67
- severity: /@#{AllureCucumber.configuration.severity_prefix}(?<severity>\S+)/,
68
- flaky: /@flaky/,
69
- muted: /@muted/,
70
- known: /@known/
71
- }
72
- end
73
-
74
- # @param [String] tag
75
- # @return [Boolean]
76
- def reserved?(tag)
77
- reserved_patterns.values.any? { |pattern| tag.match?(pattern) }
78
- end
79
- end
80
- end