allure-cucumber 2.13.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/allure_cucumber/cucumber_model.rb +104 -106
- data/lib/allure_cucumber/formatter.rb +15 -12
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec242b1ce862dc86cbf68c7856daa57f683796581e4433af79b4ad7a55b9a783
|
4
|
+
data.tar.gz: fd36406dead4a7ba6fe504bf48b6a97b6a99ef2063820fe56426619f44df8460
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e924c3a2e4a7ea1ce3b8b598f0f1ebed4b7a9299653b412b80588e4926b87e010b79557d0e2c83ef32a3c186b6638c5867d13e99f8af94791ded9e8e0d8bbb98
|
7
|
+
data.tar.gz: 6a22c0c59c031df736423e71826d2da0a9a64e3ac3672ff41edc6f85e50dccab817976fe73ae46da4a744ed94b7165133e6405dbe5611e1f414a4484f289c96f
|
@@ -10,128 +10,126 @@ require_relative "tag_parser"
|
|
10
10
|
|
11
11
|
module AllureCucumber
|
12
12
|
# Support class for transforming cucumber test entities in to allure model entities
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
13
|
+
module AllureCucumberModel
|
14
|
+
include AstTransformer
|
15
|
+
include TagParser
|
16
|
+
|
17
|
+
# Convert to allure test result
|
18
|
+
# @param [Cucumber::Core::Test::Case] test_case
|
19
|
+
# @return [TestResult]
|
20
|
+
def test_result(test_case)
|
21
|
+
Allure::TestResult.new(
|
22
|
+
name: test_case.name,
|
23
|
+
description: description(test_case),
|
24
|
+
description_html: description(test_case),
|
25
|
+
history_id: Digest::MD5.hexdigest(test_case.inspect),
|
26
|
+
full_name: "#{test_case.feature.name}: #{test_case.name}",
|
27
|
+
labels: labels(test_case),
|
28
|
+
links: links(test_case),
|
29
|
+
parameters: parameters(test_case) || [],
|
30
|
+
status_details: Allure::StatusDetails.new(**status_detail_tags(test_case.tags.map(&:name))),
|
31
|
+
)
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
# Convert to allure step result
|
35
|
+
# @param [Cucumber::Core::Test::Step] test_step
|
36
|
+
# @return [StepResult]
|
37
|
+
def step_result(test_step)
|
38
|
+
Allure::StepResult.new(
|
39
|
+
name: "#{step(test_step).keyword}#{test_step.text}",
|
40
|
+
attachments: [multiline_arg_attachment(test_step)].compact,
|
41
|
+
)
|
42
|
+
end
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
# Convert to allure step result
|
45
|
+
# @param [Cucumber::Core::Test::Step] test_step
|
46
|
+
# @return [StepResult]
|
47
|
+
def fixture_result(test_step)
|
48
|
+
location = test_step.location.to_s.split("/").last
|
49
|
+
Allure::FixtureResult.new(name: location)
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
52
|
+
# Get failure details
|
53
|
+
# @param [Cucumber::Core::Test::Result] result <description>
|
54
|
+
# @return [Hash<Symbol, String>]
|
55
|
+
def failure_details(result)
|
56
|
+
return { message: result.exception.message, trace: result.exception.backtrace.join("\n") } if result.failed?
|
57
|
+
return { message: result.message, trace: result.backtrace.join("\n") } if result.undefined?
|
59
58
|
|
60
|
-
|
61
|
-
|
59
|
+
{}
|
60
|
+
end
|
62
61
|
|
63
|
-
|
62
|
+
# Get thread specific lifecycle
|
63
|
+
# @return [Allure::AllureLifecycle]
|
64
|
+
def lifecycle
|
65
|
+
Allure.lifecycle
|
66
|
+
end
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
68
|
+
private
|
69
|
+
|
70
|
+
# @param [Cucumber::Core::Test::Case] test_case
|
71
|
+
# @return [Array<Allure::Label>]
|
72
|
+
def labels(test_case)
|
73
|
+
labels = []
|
74
|
+
labels << Allure::ResultUtils.framework_label("cucumber")
|
75
|
+
labels << Allure::ResultUtils.feature_label(test_case.feature.name)
|
76
|
+
labels << Allure::ResultUtils.package_label(test_case.feature.name)
|
77
|
+
labels << Allure::ResultUtils.suite_label(test_case.feature.name)
|
78
|
+
labels << Allure::ResultUtils.story_label(test_case.name)
|
79
|
+
labels << Allure::ResultUtils.test_class_label(test_case.name)
|
80
|
+
unless test_case.tags.empty?
|
81
|
+
labels.push(*tag_labels(test_case.tags))
|
82
|
+
labels << severity(test_case.tags)
|
69
83
|
end
|
70
84
|
|
71
|
-
|
72
|
-
|
73
|
-
def labels(test_case)
|
74
|
-
labels = []
|
75
|
-
labels << Allure::ResultUtils.framework_label("cucumber")
|
76
|
-
labels << Allure::ResultUtils.feature_label(test_case.feature.name)
|
77
|
-
labels << Allure::ResultUtils.package_label(test_case.feature.name)
|
78
|
-
labels << Allure::ResultUtils.suite_label(test_case.feature.name)
|
79
|
-
labels << Allure::ResultUtils.story_label(test_case.name)
|
80
|
-
labels << Allure::ResultUtils.test_class_label(test_case.name)
|
81
|
-
unless test_case.tags.empty?
|
82
|
-
labels.push(*tag_labels(test_case.tags))
|
83
|
-
labels << severity(test_case.tags)
|
84
|
-
end
|
85
|
-
|
86
|
-
labels
|
87
|
-
end
|
85
|
+
labels
|
86
|
+
end
|
88
87
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
88
|
+
# @param [Cucumber::Core::Test::Case] test_case
|
89
|
+
# @return [Array<Allure::Link>]
|
90
|
+
def links(test_case)
|
91
|
+
return [] unless test_case.tags
|
93
92
|
|
94
|
-
|
95
|
-
|
93
|
+
tms_links(test_case.tags) + issue_links(test_case.tags)
|
94
|
+
end
|
96
95
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
96
|
+
# @param [Cucumber::Core::Test::Case] test_case
|
97
|
+
# @return [Array<Allure::Parameter>]
|
98
|
+
def parameters(test_case)
|
99
|
+
example_row(test_case)&.values&.map { |value| Allure::Parameter.new("argument", value) }
|
100
|
+
end
|
102
101
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
102
|
+
# @param [Cucumber::Core::Test::Case] test_case
|
103
|
+
# @return [String]
|
104
|
+
def description(test_case)
|
105
|
+
scenario = scenario(test_case)
|
106
|
+
scenario.description.empty? ? "Location - #{scenario.file_colon_line}" : scenario.description.strip
|
107
|
+
end
|
109
108
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
109
|
+
# @param [Cucumber::Core::Test::Step] test_step
|
110
|
+
# @return [Allure::Attachment]
|
111
|
+
def multiline_arg_attachment(test_step)
|
112
|
+
arg = multiline_arg(test_step)
|
113
|
+
return unless arg
|
115
114
|
|
116
|
-
|
117
|
-
|
115
|
+
arg.data_table? ? data_table_attachment(arg) : docstring_attachment(arg)
|
116
|
+
end
|
118
117
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
118
|
+
# @param [Cucumber::Core::Ast::DataTable] multiline_arg
|
119
|
+
# @return [Allure::Attachment]
|
120
|
+
def data_table_attachment(multiline_arg)
|
121
|
+
attachment = lifecycle.prepare_attachment("data-table", Allure::ContentType::CSV)
|
122
|
+
csv = multiline_arg.raw.each_with_object([]) { |row, arr| arr.push(row.to_csv) }.join("")
|
123
|
+
lifecycle.write_attachment(csv, attachment)
|
124
|
+
attachment
|
125
|
+
end
|
127
126
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
end
|
127
|
+
# @param [String] multiline_arg
|
128
|
+
# @return [String]
|
129
|
+
def docstring_attachment(multiline_arg)
|
130
|
+
attachment = lifecycle.prepare_attachment("docstring", Allure::ContentType::TXT)
|
131
|
+
lifecycle.write_attachment(multiline_arg.content, attachment)
|
132
|
+
attachment
|
135
133
|
end
|
136
134
|
end
|
137
135
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "fileutils"
|
4
3
|
require_relative "cucumber_model"
|
5
4
|
|
6
5
|
module AllureCucumber
|
7
6
|
# Main formatter class. Translates cucumber event to allure lifecycle
|
8
7
|
class CucumberFormatter
|
8
|
+
include AllureCucumberModel
|
9
|
+
|
9
10
|
# @return [Hash] hook handler methods
|
10
11
|
HOOK_HANDLERS = {
|
11
12
|
"Before hook" => :start_prepare_fixture,
|
@@ -22,20 +23,28 @@ module AllureCucumber
|
|
22
23
|
def initialize(config)
|
23
24
|
Allure.configure do |c|
|
24
25
|
c.results_directory = config.out_stream if config.out_stream.is_a?(String)
|
25
|
-
FileUtils.rm_f(Dir.glob("#{c.results_directory}/*")) if c.clean_results_directory
|
26
26
|
end
|
27
|
+
|
28
|
+
config.on_event(:test_run_started, &method(:on_test_run_started))
|
27
29
|
config.on_event(:test_case_started, &method(:on_test_case_started))
|
28
30
|
config.on_event(:test_step_started, &method(:on_test_step_started))
|
29
31
|
config.on_event(:test_step_finished, &method(:on_test_step_finished))
|
30
32
|
config.on_event(:test_case_finished, &method(:on_test_case_finished))
|
31
33
|
end
|
32
34
|
|
35
|
+
# Clean test result directory before starting run
|
36
|
+
# @param [Cucumber::Events::TestRunStarted<Type>] _event
|
37
|
+
# @return [void]
|
38
|
+
def on_test_run_started(_event)
|
39
|
+
lifecycle.clean_results_dir
|
40
|
+
end
|
41
|
+
|
33
42
|
# Handle test case started event
|
34
43
|
# @param [Cucumber::Core::Events::TestCaseStarted] event
|
35
44
|
# @return [void]
|
36
45
|
def on_test_case_started(event)
|
37
46
|
lifecycle.start_test_container(Allure::TestResultContainer.new(name: event.test_case.name))
|
38
|
-
lifecycle.start_test_case(
|
47
|
+
lifecycle.start_test_case(test_result(event.test_case))
|
39
48
|
end
|
40
49
|
|
41
50
|
# Handle test step started event
|
@@ -65,7 +74,7 @@ module AllureCucumber
|
|
65
74
|
# @param [Cucumber::Core::Events::TestCaseFinished] event
|
66
75
|
# @return [void]
|
67
76
|
def on_test_case_finished(event)
|
68
|
-
failure_details =
|
77
|
+
failure_details = failure_details(event.result)
|
69
78
|
status = ALLURE_STATUS.fetch(event.result.to_sym, Allure::Status::BROKEN)
|
70
79
|
lifecycle.update_test_case do |test_case|
|
71
80
|
test_case.stage = Allure::Stage::FINISHED
|
@@ -80,12 +89,6 @@ module AllureCucumber
|
|
80
89
|
|
81
90
|
private
|
82
91
|
|
83
|
-
# Get thread specific lifecycle
|
84
|
-
# @return [Allure::AllureLifecycle]
|
85
|
-
def lifecycle
|
86
|
-
Allure.lifecycle
|
87
|
-
end
|
88
|
-
|
89
92
|
# @param [Cucumber::Core::Test::Step] test_step <description>
|
90
93
|
# @return [Boolean]
|
91
94
|
def hook?(test_step)
|
@@ -101,7 +104,7 @@ module AllureCucumber
|
|
101
104
|
# @param [Cucumber::Core::Test::Step] test_step
|
102
105
|
# @return [void]
|
103
106
|
def handle_step_started(test_step)
|
104
|
-
lifecycle.start_test_step(
|
107
|
+
lifecycle.start_test_step(step_result(test_step))
|
105
108
|
end
|
106
109
|
|
107
110
|
# @param [Cucumber::Core::Test::Step] test_step
|
@@ -109,7 +112,7 @@ module AllureCucumber
|
|
109
112
|
def handle_hook_started(test_step)
|
110
113
|
return if prepare_world_hook?(test_step)
|
111
114
|
|
112
|
-
lifecycle.public_send(HOOK_HANDLERS[test_step.text],
|
115
|
+
lifecycle.public_send(HOOK_HANDLERS[test_step.text], fixture_result(test_step))
|
113
116
|
end
|
114
117
|
end
|
115
118
|
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.
|
4
|
+
version: 2.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrejs Cunskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09
|
11
|
+
date: 2019-10-09 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.1
|
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.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: cucumber
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,7 +54,12 @@ files:
|
|
54
54
|
homepage: https://github.com/allure-framework/allure-ruby
|
55
55
|
licenses:
|
56
56
|
- Apache-2.0
|
57
|
-
metadata:
|
57
|
+
metadata:
|
58
|
+
bug_tracker_uri: https://github.com/allure-framework/allure-ruby/issues
|
59
|
+
changelog_uri: https://github.com/allure-framework/allure-ruby/releases
|
60
|
+
documentation_uri: https://github.com/allure-framework/allure-ruby/blob/master/allure-cucumber/README.md
|
61
|
+
source_code_uri: https://github.com/allure-framework/allure-ruby/tree/master/allure-cucumber
|
62
|
+
wiki_uri: https://github.com/allure-framework/allure-ruby/wiki
|
58
63
|
post_install_message:
|
59
64
|
rdoc_options: []
|
60
65
|
require_paths:
|