allure-cucumber 2.13.8.1 → 2.13.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -3
- data/lib/allure-cucumber.rb +1 -2
- data/lib/allure_cucumber/config.rb +21 -0
- data/lib/allure_cucumber/formatter.rb +29 -6
- data/lib/allure_cucumber/models/cucumber_model.rb +6 -41
- data/lib/allure_cucumber/models/metadata_parser.rb +137 -0
- data/lib/allure_cucumber/models/scenario.rb +4 -4
- metadata +8 -8
- data/lib/allure_cucumber/models/tag_parser.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df0a75ebcd25e7169150696e4745ecef51e069a71e7491ec8317ee32b09c8bd8
|
4
|
+
data.tar.gz: 659024e9b7ca69d939a2908e629a92efa62d8b68d0ff32946fdc844f1f58bf01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: badd202150dedfb6ce97d4f84acafa015ca19cf96cb4e4074c100cfcf057d1bd2a3f18dfe91b87ac2b03083a5ba59883d342807fda3600fbbaf84285215139db
|
7
|
+
data.tar.gz: 8f80df33fafc4a7f60c27524f586182d55d3e290d48630ccf871766c2e09c2c50fc74ce4d0a225fb3d3831f6cdcefd3101226dc425d9e2b08a6318b60d54128c
|
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
|
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)
|
data/lib/allure-cucumber.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
34
|
-
links: links
|
35
|
-
parameters: parameters
|
36
|
-
status_details:
|
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(
|
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
|
@@ -34,9 +34,7 @@ module AllureCucumber
|
|
34
34
|
# Scenario description or it's location
|
35
35
|
# @return [String]
|
36
36
|
def description
|
37
|
-
@description ||=
|
38
|
-
scenario.description.empty? ? "Location - #{test_case.location}" : scenario.description.strip
|
39
|
-
end
|
37
|
+
@description ||= scenario.description.empty? ? "Location - #{test_case.location}" : scenario.description.strip
|
40
38
|
end
|
41
39
|
|
42
40
|
# Scenario outline row parameters
|
@@ -86,7 +84,9 @@ module AllureCucumber
|
|
86
84
|
# @return [String]
|
87
85
|
def example_row
|
88
86
|
@example_row ||= begin
|
89
|
-
|
87
|
+
scneario_examples = scenario_source.examples.table_body.index { |row| row.id == scenario_source.row.id } + 1
|
88
|
+
|
89
|
+
"Examples (##{scneario_examples})"
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
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.
|
4
|
+
version: 2.13.9
|
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-
|
11
|
+
date: 2021-04-15 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.
|
19
|
+
version: 2.13.9
|
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.
|
26
|
+
version: 2.13.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: cucumber
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: 4.0.0
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '7'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 4.0.0
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '7'
|
47
47
|
description: Cucumber adaptor to generate rich allure test reports
|
48
48
|
email: andrejs.cunskis@gmail.com
|
49
49
|
executables: []
|
@@ -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.2.
|
85
|
+
rubygems_version: 3.2.15
|
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
|