allure-cucumber 2.13.8.3 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -4
- data/lib/allure-cucumber.rb +3 -4
- data/lib/allure_cucumber/config.rb +49 -7
- data/lib/allure_cucumber/formatter.rb +35 -17
- data/lib/allure_cucumber/models/cucumber_model.rb +10 -43
- data/lib/allure_cucumber/models/metadata_parser.rb +145 -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: f4c956f1d985e00f19d6da37325be18c3a99dffd6973d5132eee060e54fa074f
|
4
|
+
data.tar.gz: 4b52abbad313cd0e1f7dba8121db306d9ce470e7a3d29bc36d5a87cfa23fb94c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8edfba0e3f760f80c47c4a9437d231106c43babc3517a9af42012d301752c9a7c03dac04c2e2230ae919d8758c3bee60f5e1d3a7d4d81006f6e58b3b066b075
|
7
|
+
data.tar.gz: fd609abae4fce07177657406b6090412aa68fa7780ecee4883e773bd060890544a57fbdb10016bfdedfd19105e3b3fe6f4a6702294182ffe8d1e3aa78898a223
|
data/README.md
CHANGED
@@ -43,27 +43,36 @@ Common allure configuration is set via `AllureCucumber.configure` method. To cha
|
|
43
43
|
require "allure-cucumber"
|
44
44
|
|
45
45
|
AllureCucumber.configure do |config|
|
46
|
-
config.results_directory = "/
|
46
|
+
config.results_directory = "report/allure-results"
|
47
47
|
config.clean_results_directory = true
|
48
48
|
config.logging_level = Logger::INFO
|
49
|
+
config.logger = Logger.new($stdout, Logger::DEBUG)
|
50
|
+
config.environment = "staging"
|
51
|
+
|
49
52
|
# these are used for creating links to bugs or test cases where {} is replaced with keys of relevant items
|
50
53
|
config.link_tms_pattern = "http://www.jira.com/browse/{}"
|
51
54
|
config.link_issue_pattern = "http://www.jira.com/browse/{}"
|
52
55
|
end
|
53
56
|
```
|
54
57
|
|
55
|
-
By default, allure-cucumber will analyze your cucumber tags looking for Test Management, Issue Management, and Severity tag
|
58
|
+
By default, allure-cucumber will analyze your cucumber tags looking for Test Management, Issue Management, and Severity tag as well
|
59
|
+
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.
|
60
|
+
|
61
|
+
By default these prefixes are used:
|
56
62
|
|
57
63
|
```ruby
|
58
64
|
DEFAULT_TMS_PREFIX = 'TMS:'
|
59
65
|
DEFAULT_ISSUE_PREFIX = 'ISSUE:'
|
60
66
|
DEFAULT_SEVERITY_PREFIX = 'SEVERITY:'
|
67
|
+
DEFAULT_EPIC_PREFIX = 'EPIC:'
|
68
|
+
DEFAULT_FEATURE_PREFIX = 'FEATURE:'
|
69
|
+
DEFAULT_STORY_PREFIX = 'STORY:'
|
61
70
|
```
|
62
71
|
|
63
72
|
Example:
|
64
73
|
|
65
74
|
```gherkin
|
66
|
-
@SEVERITY:trivial @ISSUE:YZZ-100 @TMS:9901
|
75
|
+
@SEVERITY:trivial @ISSUE:YZZ-100 @TMS:9901 @EPIC:custom-epic
|
67
76
|
Scenario: Leave First Name Blank
|
68
77
|
When I register an account without a first name
|
69
78
|
Then exactly (1) [validation_error] should be visible
|
@@ -76,13 +85,16 @@ AllureCucumber.configure do |config|
|
|
76
85
|
config.tms_prefix = 'HIPTEST--'
|
77
86
|
config.issue_prefix = 'JIRA++'
|
78
87
|
config.severity_prefix = 'URGENCY:'
|
88
|
+
config.epic_prefix = 'epic:'
|
89
|
+
config.feature_prefix = 'feature:'
|
90
|
+
config.story_prefix = 'story:'
|
79
91
|
end
|
80
92
|
```
|
81
93
|
|
82
94
|
Example:
|
83
95
|
|
84
96
|
```gherkin
|
85
|
-
@URGENCY:critical @JIRA++YZZ-100 @HIPTEST--9901
|
97
|
+
@URGENCY:critical @JIRA++YZZ-100 @HIPTEST--9901 @epic:custom-epic
|
86
98
|
Scenario: Leave First Name Blank
|
87
99
|
When I register an account without a first name
|
88
100
|
Then exactly (1) [validation_error] should be visible
|
data/lib/allure-cucumber.rb
CHANGED
@@ -3,20 +3,19 @@
|
|
3
3
|
|
4
4
|
require "allure-ruby-commons"
|
5
5
|
|
6
|
-
|
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
|
11
10
|
class << self
|
12
11
|
# Get allure cucumber configuration
|
13
|
-
# @return [
|
12
|
+
# @return [AllureCucumber::CucumberConfig]
|
14
13
|
def configuration
|
15
14
|
CucumberConfig.instance
|
16
15
|
end
|
17
16
|
|
18
17
|
# Set allure configuration
|
19
|
-
# @yieldparam [
|
18
|
+
# @yieldparam [AllureCucumber::CucumberConfig]
|
20
19
|
# @yieldreturn [void]
|
21
20
|
# @return [void]
|
22
21
|
def configure
|
@@ -1,11 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "singleton"
|
4
|
-
require "forwardable"
|
5
4
|
|
6
5
|
module AllureCucumber
|
7
|
-
# Allure
|
8
|
-
|
6
|
+
# Allure Cucumber configuration class
|
7
|
+
#
|
8
|
+
# @!attribute results_directory
|
9
|
+
# @return [String]
|
10
|
+
# @!attribute clean_results_directory
|
11
|
+
# @return [Boolean]
|
12
|
+
# @!attribute link_issue_pattern
|
13
|
+
# @return [String]
|
14
|
+
# @!attribute link_tms_pattern
|
15
|
+
# @return [String]
|
16
|
+
# @!attribute logging_level
|
17
|
+
# @return [Integer]
|
18
|
+
# @!attribute [r] logger
|
19
|
+
# @return [Logger]
|
20
|
+
# @!attribute environment
|
21
|
+
# @return [String]
|
22
|
+
class CucumberConfig
|
9
23
|
include Singleton
|
10
24
|
extend Forwardable
|
11
25
|
|
@@ -15,6 +29,12 @@ module AllureCucumber
|
|
15
29
|
DEFAULT_ISSUE_PREFIX = "ISSUE:"
|
16
30
|
# @return [String] default severity tag prefix
|
17
31
|
DEFAULT_SEVERITY_PREFIX = "SEVERITY:"
|
32
|
+
# @return [String] default epic tag prefix
|
33
|
+
DEFAULT_EPIC_PREFIX = "EPIC:"
|
34
|
+
# @return [String] default feature tag prefix
|
35
|
+
DEFAULT_FEATURE_PREFIX = "FEATURE:"
|
36
|
+
# @return [String] default story tag prefix
|
37
|
+
DEFAULT_STORY_PREFIX = "STORY:"
|
18
38
|
|
19
39
|
def_delegators :@allure_config,
|
20
40
|
:clean_results_directory,
|
@@ -25,14 +45,21 @@ module AllureCucumber
|
|
25
45
|
:link_tms_pattern=,
|
26
46
|
:logging_level,
|
27
47
|
:logging_level=,
|
48
|
+
:logger,
|
49
|
+
:logger=,
|
28
50
|
:results_directory,
|
29
|
-
:results_directory
|
51
|
+
:results_directory=,
|
52
|
+
:environment,
|
53
|
+
:environment=
|
30
54
|
|
31
|
-
attr_writer :tms_prefix,
|
55
|
+
attr_writer :tms_prefix,
|
56
|
+
:issue_prefix,
|
57
|
+
:severity_prefix,
|
58
|
+
:epic_prefix,
|
59
|
+
:feature_prefix,
|
60
|
+
:story_prefix
|
32
61
|
|
33
62
|
def initialize
|
34
|
-
super()
|
35
|
-
|
36
63
|
@allure_config = Allure.configuration
|
37
64
|
end
|
38
65
|
|
@@ -50,5 +77,20 @@ module AllureCucumber
|
|
50
77
|
def severity_prefix
|
51
78
|
@severity_prefix || DEFAULT_SEVERITY_PREFIX
|
52
79
|
end
|
80
|
+
|
81
|
+
# @return [String]
|
82
|
+
def epic_prefix
|
83
|
+
@epic_prefix || DEFAULT_EPIC_PREFIX
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [String]
|
87
|
+
def feature_prefix
|
88
|
+
@feature_prefix || DEFAULT_FEATURE_PREFIX
|
89
|
+
end
|
90
|
+
|
91
|
+
# @return [String]
|
92
|
+
def story_prefix
|
93
|
+
@story_prefix || DEFAULT_STORY_PREFIX
|
94
|
+
end
|
53
95
|
end
|
54
96
|
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
|
@@ -21,14 +19,15 @@ module AllureCucumber
|
|
21
19
|
|
22
20
|
# @param [Cucumber::Configuration] config
|
23
21
|
def initialize(config)
|
24
|
-
|
25
|
-
|
22
|
+
allure_config = AllureCucumber.configuration
|
23
|
+
allure_config.results_directory = config.out_stream if config.out_stream.is_a?(String)
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
Allure.lifecycle = @lifecycle = Allure::AllureLifecycle.new(allure_config)
|
26
|
+
|
27
|
+
@cucumber_model ||= AllureCucumberModel.new(config, allure_config)
|
30
28
|
|
31
|
-
|
29
|
+
names = Allure::TestPlan.test_names
|
30
|
+
config.name_regexps.push(*names.map { |name| /#{name}/ }) if names
|
32
31
|
|
33
32
|
config.on_event(:test_run_started) { |event| on_test_run_started(event) }
|
34
33
|
config.on_event(:test_case_started) { |event| on_test_case_started(event) }
|
@@ -67,10 +66,8 @@ module AllureCucumber
|
|
67
66
|
step.stage = Allure::Stage::FINISHED
|
68
67
|
step.status = ALLURE_STATUS.fetch(event.result.to_sym, Allure::Status::BROKEN)
|
69
68
|
end
|
70
|
-
step_type = event.test_step.hook? ? "fixture" : "test_step"
|
71
69
|
|
72
|
-
|
73
|
-
lifecycle.public_send("stop_#{step_type}")
|
70
|
+
event.test_step.hook? ? handle_hook_finished(event.test_step, update_block) : handle_step_finished(update_block)
|
74
71
|
end
|
75
72
|
|
76
73
|
# Handle test case finished event
|
@@ -92,12 +89,13 @@ module AllureCucumber
|
|
92
89
|
|
93
90
|
private
|
94
91
|
|
95
|
-
|
92
|
+
attr_reader :lifecycle, :cucumber_model
|
96
93
|
|
97
|
-
#
|
98
|
-
# @
|
99
|
-
|
100
|
-
|
94
|
+
# Is hook fixture like Before, After or Step as AfterStep
|
95
|
+
# @param [String] text
|
96
|
+
# @return [boolean]
|
97
|
+
def fixture_hook?(text)
|
98
|
+
HOOK_HANDLERS.key?(text)
|
101
99
|
end
|
102
100
|
|
103
101
|
# @param [Cucumber::Core::Test::Step] test_step
|
@@ -111,7 +109,27 @@ module AllureCucumber
|
|
111
109
|
# @param [Cucumber::Core::Test::HookStep] hook_step
|
112
110
|
# @return [void]
|
113
111
|
def handle_hook_started(hook_step)
|
114
|
-
|
112
|
+
result = cucumber_model.fixture_result(hook_step)
|
113
|
+
return lifecycle.start_test_step(result) unless fixture_hook?(hook_step.text)
|
114
|
+
|
115
|
+
lifecycle.public_send(HOOK_HANDLERS[hook_step.text], result)
|
116
|
+
end
|
117
|
+
|
118
|
+
# @param [Proc] update_block
|
119
|
+
# @return [void]
|
120
|
+
def handle_step_finished(update_block)
|
121
|
+
lifecycle.update_test_step(&update_block)
|
122
|
+
lifecycle.stop_test_step
|
123
|
+
end
|
124
|
+
|
125
|
+
# @param [Cucumber::Core::Test::HookStep] hook_step
|
126
|
+
# @param [Proc] update_block
|
127
|
+
# @return [void]
|
128
|
+
def handle_hook_finished(hook_step, update_block)
|
129
|
+
return handle_step_finished(update_block) unless fixture_hook?(hook_step.text)
|
130
|
+
|
131
|
+
lifecycle.update_fixture(&update_block)
|
132
|
+
lifecycle.stop_fixture
|
115
133
|
end
|
116
134
|
end
|
117
135
|
end
|
@@ -4,18 +4,13 @@ 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
|
-
def initialize(config)
|
11
|
+
def initialize(config, allure_config)
|
18
12
|
@ast_lookup = Cucumber::Formatter::AstLookup.new(config)
|
13
|
+
@config = allure_config
|
19
14
|
end
|
20
15
|
|
21
16
|
# Convert to allure test result
|
@@ -23,6 +18,7 @@ module AllureCucumber
|
|
23
18
|
# @return [Allure::TestResult]
|
24
19
|
def test_result(test_case)
|
25
20
|
scenario = Scenario.new(test_case, ast_lookup)
|
21
|
+
parser = MetadataParser.new(scenario, config)
|
26
22
|
|
27
23
|
Allure::TestResult.new(
|
28
24
|
name: scenario.name,
|
@@ -30,10 +26,11 @@ module AllureCucumber
|
|
30
26
|
description_html: scenario.description,
|
31
27
|
history_id: scenario.id,
|
32
28
|
full_name: scenario.name,
|
33
|
-
labels: labels
|
34
|
-
links: links
|
35
|
-
parameters: parameters
|
36
|
-
status_details:
|
29
|
+
labels: parser.labels,
|
30
|
+
links: parser.links,
|
31
|
+
parameters: parser.parameters,
|
32
|
+
status_details: parser.status_details,
|
33
|
+
environment: config.environment
|
37
34
|
)
|
38
35
|
end
|
39
36
|
|
@@ -55,7 +52,7 @@ module AllureCucumber
|
|
55
52
|
# @param [Cucumber::Core::Test::HookStep] hook_step
|
56
53
|
# @return [Allure::StepResult]
|
57
54
|
def fixture_result(hook_step)
|
58
|
-
Allure::FixtureResult.new(name: hook_step.location.to_s.split(
|
55
|
+
Allure::FixtureResult.new(name: "#{hook_step.text} (#{hook_step.location.to_s.split('/').last})")
|
59
56
|
end
|
60
57
|
|
61
58
|
# Get failure details
|
@@ -70,37 +67,7 @@ module AllureCucumber
|
|
70
67
|
|
71
68
|
private
|
72
69
|
|
73
|
-
attr_reader :ast_lookup, :
|
74
|
-
|
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
|
70
|
+
attr_reader :ast_lookup, :config
|
104
71
|
|
105
72
|
# @param [Step] step
|
106
73
|
# @return [Array<Allure::Attachment>]
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AllureCucumber
|
4
|
+
# Cucumber tag parser helper methods
|
5
|
+
class MetadataParser
|
6
|
+
# Metadata parser instance
|
7
|
+
#
|
8
|
+
# @param [AllureCucumber::Scenario] scenario
|
9
|
+
# @param [AllureCucumber::CucumberConfig] config
|
10
|
+
def initialize(scenario, config)
|
11
|
+
@scenario = scenario
|
12
|
+
@config = config
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Array<Allure::Label>]
|
16
|
+
def labels
|
17
|
+
[
|
18
|
+
Allure::ResultUtils.framework_label("cucumber"),
|
19
|
+
Allure::ResultUtils.package_label(scenario.feature_folder),
|
20
|
+
Allure::ResultUtils.test_class_label(scenario.feature_file_name),
|
21
|
+
Allure::ResultUtils.suite_label(scenario.feature_name),
|
22
|
+
severity,
|
23
|
+
*behavior_labels,
|
24
|
+
*tag_labels
|
25
|
+
].select(&:value)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Array<Allure::Label>]
|
29
|
+
def tag_labels
|
30
|
+
tags
|
31
|
+
.reject { |tag| reserved?(tag) }
|
32
|
+
.map { |tag| Allure::ResultUtils.tag_label(tag.delete_prefix("@")) }
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param [Cucumber::Core::Test::Case] test_case
|
36
|
+
# @return [Array<Allure::Link>]
|
37
|
+
def links
|
38
|
+
tms_links + issue_links
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [Allure::Label]
|
42
|
+
def severity
|
43
|
+
Allure::ResultUtils.severity_label(tag_value(:severity) || "normal")
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [Array<Allure::Parameter>]
|
47
|
+
def parameters
|
48
|
+
scenario.examples.map { |k, v| Allure::Parameter.new(k, v) }
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [Hash<Symbol, Boolean>]
|
52
|
+
def status_details
|
53
|
+
Allure::StatusDetails.new(
|
54
|
+
flaky: tags.any? { |tag| tag.match?(reserved_patterns[:flaky]) },
|
55
|
+
muted: tags.any? { |tag| tag.match?(reserved_patterns[:muted]) },
|
56
|
+
known: tags.any? { |tag| tag.match?(reserved_patterns[:known]) }
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Get behavior labels
|
61
|
+
# @return [Array<Allure::Label>]
|
62
|
+
def behavior_labels
|
63
|
+
epic = tag_value(:epic) || scenario.feature_folder
|
64
|
+
feature = tag_value(:feature) || scenario.feature_name
|
65
|
+
story = tag_value(:story)
|
66
|
+
|
67
|
+
[
|
68
|
+
Allure::ResultUtils.epic_label(epic),
|
69
|
+
Allure::ResultUtils.feature_label(feature),
|
70
|
+
Allure::ResultUtils.story_label(story)
|
71
|
+
]
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
attr_reader :scenario, :config
|
77
|
+
|
78
|
+
# Get scenario tags
|
79
|
+
#
|
80
|
+
# @return [Array<String>]
|
81
|
+
def tags
|
82
|
+
@tags ||= scenario.tags
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [Array<Allure::Link>]
|
86
|
+
def tms_links
|
87
|
+
return [] unless config.link_tms_pattern
|
88
|
+
|
89
|
+
matching_links(:tms)
|
90
|
+
end
|
91
|
+
|
92
|
+
# @return [Array<Allure::Link>]
|
93
|
+
def issue_links
|
94
|
+
return [] unless config.link_issue_pattern
|
95
|
+
|
96
|
+
matching_links(:issue)
|
97
|
+
end
|
98
|
+
|
99
|
+
# @param [Symbol] type
|
100
|
+
# @return [Array<Allure::Link>]
|
101
|
+
def matching_links(type)
|
102
|
+
pattern = reserved_patterns[type]
|
103
|
+
link_pattern = config.public_send("link_#{type}_pattern")
|
104
|
+
|
105
|
+
tags
|
106
|
+
.select { |tag| tag.match?(pattern) }
|
107
|
+
.map do |tag|
|
108
|
+
tag.match(pattern) { |match| Allure::ResultUtils.public_send("#{type}_link", match[type], link_pattern) }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# @return [Hash<Symbol, Regexp>]
|
113
|
+
def reserved_patterns
|
114
|
+
@reserved_patterns ||= {
|
115
|
+
tms: /@#{config.tms_prefix}(?<tms>\S+)/,
|
116
|
+
issue: /@#{config.issue_prefix}(?<issue>\S+)/,
|
117
|
+
severity: /@#{config.severity_prefix}(?<severity>\S+)/,
|
118
|
+
epic: /@#{config.epic_prefix}(?<epic>\S+)/,
|
119
|
+
feature: /@#{config.feature_prefix}(?<feature>\S+)/,
|
120
|
+
story: /@#{config.story_prefix}(?<story>\S+)/,
|
121
|
+
flaky: /@flaky/,
|
122
|
+
muted: /@muted/,
|
123
|
+
known: /@known/
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
# @param [String] tag
|
128
|
+
# @return [Boolean]
|
129
|
+
def reserved?(tag)
|
130
|
+
reserved_patterns.values.any? { |pattern| tag.match?(pattern) }
|
131
|
+
end
|
132
|
+
|
133
|
+
# Get specific tag value
|
134
|
+
#
|
135
|
+
# @param [Symbol] type
|
136
|
+
# @return [String]
|
137
|
+
def tag_value(type)
|
138
|
+
pattern = reserved_patterns[type]
|
139
|
+
tag = tags.detect { |t| t.match?(pattern) }
|
140
|
+
return unless tag
|
141
|
+
|
142
|
+
tag.match(pattern)[type]
|
143
|
+
end
|
144
|
+
end
|
145
|
+
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.
|
4
|
+
version: 2.14.0
|
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-05-25 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.
|
19
|
+
version: 2.14.0
|
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.
|
26
|
+
version: 2.14.0
|
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
|