allure-cucumber 2.10.0.beta3 → 2.13.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 +22 -13
- data/lib/allure-cucumber.rb +2 -1
- data/lib/allure_cucumber/ast_transformer.rb +4 -5
- data/lib/allure_cucumber/config.rb +6 -2
- data/lib/allure_cucumber/cucumber_model.rb +13 -13
- data/lib/allure_cucumber/formatter.rb +16 -10
- data/lib/allure_cucumber/tag_parser.rb +8 -7
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a40fd70805beafb477df5371f9e8f7c0f66cee6c8243b484141eb7b32c9a1026
|
4
|
+
data.tar.gz: f555048bb7569ecee757c15082e384d30f89eb5d15799317084a8655a1f478bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac13c7c3b417e00809b05c584f695539f585aaf8712c58c15998049c1dc8382a5a8aea4bad87d783a5c3a85f224a53f29939dad7b11ba8a3b428b9ee20a1bd97
|
7
|
+
data.tar.gz: bb7c69513879f80dd682ff78a896be2dc2d9a6994be249035ed4f9a60eecd4c5b33687ef89486add98e023faa0d0b676317055823b078d22d3b5f6c7d8745121
|
data/README.md
CHANGED
@@ -9,61 +9,69 @@ Add this line to your application's Gemfile:
|
|
9
9
|
```ruby
|
10
10
|
gem 'allure-cucumber'
|
11
11
|
```
|
12
|
+
|
12
13
|
And then execute:
|
14
|
+
|
13
15
|
```bash
|
14
|
-
$ bundle
|
16
|
+
$ bundle
|
15
17
|
```
|
16
18
|
|
17
19
|
Or install it yourself as:
|
20
|
+
|
18
21
|
```bash
|
19
|
-
$ gem install allure-cucumber
|
22
|
+
$ gem install allure-cucumber
|
20
23
|
```
|
21
24
|
|
22
25
|
## Configuration
|
23
26
|
|
24
|
-
|
27
|
+
Common allure configuration is set via `Allure.configure` method. To change id, add the following in `features/support/env.rb` file:
|
25
28
|
|
26
29
|
```ruby
|
27
30
|
Allure.configure do |c|
|
28
|
-
|
31
|
+
c.results_directory = "/whatever/you/like"
|
32
|
+
c.clean_results_directory = true
|
33
|
+
c.logging_level = Logger::INFO
|
34
|
+
# these are used for creating links to bugs or test cases where {} is replaced with keys of relevant items
|
35
|
+
c.link_tms_pattern = "http://www.jira.com/browse/{}"
|
36
|
+
c.link_issue_pattern = "http://www.jira.com/browse/{}"
|
29
37
|
end
|
30
38
|
```
|
31
39
|
|
32
40
|
By default, allure-cucumber will analyze your cucumber tags looking for Test Management, Issue Management, and Severity hooks. Links to TMS and ISSUE and test severity will be displayed in the report. By default these prefixes are used:
|
33
41
|
|
34
|
-
```ruby
|
42
|
+
```ruby
|
35
43
|
DEFAULT_TMS_PREFIX = 'TMS:'
|
36
44
|
DEFAULT_ISSUE_PREFIX = 'ISSUE:'
|
37
45
|
DEFAULT_SEVERITY_PREFIX = 'SEVERITY:'
|
38
46
|
```
|
39
47
|
|
40
|
-
Example:
|
48
|
+
Example:
|
49
|
+
|
41
50
|
```gherkin
|
42
51
|
@SEVERITY:trivial @ISSUE:YZZ-100 @TMS:9901
|
43
52
|
Scenario: Leave First Name Blank
|
44
53
|
When I register an account without a first name
|
45
54
|
Then exactly (1) [validation_error] should be visible
|
46
|
-
```
|
55
|
+
```
|
47
56
|
|
48
57
|
You can configure these prefixes as well as tms and issue tracker urls like this:
|
49
58
|
|
50
59
|
```ruby
|
51
|
-
|
52
|
-
c.link_tms_pattern = "http://www.hiptest.com/tms/{}"
|
53
|
-
c.link_issue_pattern = "http://www.jira.com/browse/{}"
|
60
|
+
AllureCucumber.configure do |c|
|
54
61
|
c.tms_prefix = 'HIPTEST--'
|
55
62
|
c.issue_prefix = 'JIRA++'
|
56
63
|
c.severity_prefix = 'URGENCY:'
|
57
64
|
end
|
58
65
|
```
|
59
66
|
|
60
|
-
Example:
|
67
|
+
Example:
|
68
|
+
|
61
69
|
```gherkin
|
62
70
|
@URGENCY:critical @JIRA++YZZ-100 @HIPTEST--9901
|
63
71
|
Scenario: Leave First Name Blank
|
64
72
|
When I register an account without a first name
|
65
73
|
Then exactly (1) [validation_error] should be visible
|
66
|
-
```
|
74
|
+
```
|
67
75
|
|
68
76
|
Additional special tags exists for setting status detail of test scenarios, allure will pick up following tags: `@flaky`, `@known` and `@muted`
|
69
77
|
|
@@ -75,7 +83,7 @@ Put the following in your `features/support/env.rb` file:
|
|
75
83
|
require 'allure-cucumber'
|
76
84
|
```
|
77
85
|
|
78
|
-
Use `--format
|
86
|
+
Use `--format AllureCucumber::CucumberFormatter --out where/you-want-results` while running cucumber or add it to `cucumber.yml`. Note that cucumber `--out` option overrides `results_directory` set via `Allure.configure` method.
|
79
87
|
|
80
88
|
You can also manually attach screenshots and links to test steps and test cases by interacting with allure lifecycle directly. For more info check out `allure-ruby-commons`
|
81
89
|
|
@@ -89,4 +97,5 @@ Allure.add_link("Custom Url", "http://www.github.com")
|
|
89
97
|
```
|
90
98
|
|
91
99
|
## How to generate report
|
100
|
+
|
92
101
|
This adaptor only generates json files containing information about tests. See [wiki section](https://docs.qameta.io/allure/#_reporting) on how to generate report.
|
data/lib/allure-cucumber.rb
CHANGED
@@ -6,7 +6,8 @@ require "allure-ruby-commons"
|
|
6
6
|
require "allure_cucumber/formatter"
|
7
7
|
require "allure_cucumber/config"
|
8
8
|
|
9
|
-
module
|
9
|
+
# Main allure-cucumber module providing configuration methods
|
10
|
+
module AllureCucumber
|
10
11
|
class << self
|
11
12
|
# Get allure cucumber configuration
|
12
13
|
# @return [Allure::CucumberConfig]
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
module Allure
|
3
|
+
module AllureCucumber
|
4
|
+
# Cucumber::Core::Ast is removed in cucumber-core 4.0 version.
|
5
|
+
# This will have to be updated accordingly, once stable version rolls out
|
7
6
|
module AstTransformer
|
8
7
|
# Get scenario object
|
9
8
|
# @param [Cucumber::Core::Test::Case] test_case
|
@@ -15,7 +14,7 @@ module Allure
|
|
15
14
|
end
|
16
15
|
|
17
16
|
# Get step object
|
18
|
-
# @param [Cucumber::Core::Test::Step]
|
17
|
+
# @param [Cucumber::Core::Test::Step] test_step
|
19
18
|
# @return [Cucumber::Core::Ast::Step]
|
20
19
|
def step(test_step)
|
21
20
|
test_step.source.detect { |it| it.is_a?(Cucumber::Core::Ast::Step) }
|
@@ -1,10 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
|
3
|
+
module AllureCucumber
|
4
|
+
# Allure cucumber configuration
|
5
|
+
class CucumberConfig
|
5
6
|
class << self
|
7
|
+
# @return [String] default tms tag prefix
|
6
8
|
DEFAULT_TMS_PREFIX = "TMS:"
|
9
|
+
# @return [String] default issue tag prefix
|
7
10
|
DEFAULT_ISSUE_PREFIX = "ISSUE:"
|
11
|
+
# @return [String] default severity tag prefix
|
8
12
|
DEFAULT_SEVERITY_PREFIX = "SEVERITY:"
|
9
13
|
|
10
14
|
attr_writer :tms_prefix, :issue_prefix, :severity_prefix
|
@@ -8,7 +8,7 @@ require "csv"
|
|
8
8
|
require_relative "ast_transformer"
|
9
9
|
require_relative "tag_parser"
|
10
10
|
|
11
|
-
module
|
11
|
+
module AllureCucumber
|
12
12
|
# Support class for transforming cucumber test entities in to allure model entities
|
13
13
|
class AllureCucumberModel
|
14
14
|
extend AstTransformer
|
@@ -19,7 +19,7 @@ module Allure
|
|
19
19
|
# @param [Cucumber::Core::Test::Case] test_case
|
20
20
|
# @return [TestResult]
|
21
21
|
def test_result(test_case)
|
22
|
-
TestResult.new(
|
22
|
+
Allure::TestResult.new(
|
23
23
|
name: test_case.name,
|
24
24
|
description: description(test_case),
|
25
25
|
description_html: description(test_case),
|
@@ -36,7 +36,7 @@ module Allure
|
|
36
36
|
# @param [Cucumber::Core::Test::Step] test_step
|
37
37
|
# @return [StepResult]
|
38
38
|
def step_result(test_step)
|
39
|
-
StepResult.new(
|
39
|
+
Allure::StepResult.new(
|
40
40
|
name: "#{step(test_step).keyword}#{test_step.text}",
|
41
41
|
attachments: [multiline_arg_attachment(test_step)].compact,
|
42
42
|
)
|
@@ -47,7 +47,7 @@ module Allure
|
|
47
47
|
# @return [StepResult]
|
48
48
|
def fixture_result(test_step)
|
49
49
|
location = test_step.location.to_s.split("/").last
|
50
|
-
FixtureResult.new(name: location)
|
50
|
+
Allure::FixtureResult.new(name: location)
|
51
51
|
end
|
52
52
|
|
53
53
|
# Get failure details
|
@@ -72,12 +72,12 @@ module Allure
|
|
72
72
|
# @return [Array<Allure::Label>]
|
73
73
|
def labels(test_case)
|
74
74
|
labels = []
|
75
|
-
labels << ResultUtils.framework_label("cucumber")
|
76
|
-
labels << ResultUtils.feature_label(test_case.feature.name)
|
77
|
-
labels << ResultUtils.package_label(test_case.feature.name)
|
78
|
-
labels << ResultUtils.suite_label(test_case.feature.name)
|
79
|
-
labels << ResultUtils.story_label(test_case.name)
|
80
|
-
labels << ResultUtils.test_class_label(test_case.name)
|
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
81
|
unless test_case.tags.empty?
|
82
82
|
labels.push(*tag_labels(test_case.tags))
|
83
83
|
labels << severity(test_case.tags)
|
@@ -97,7 +97,7 @@ module Allure
|
|
97
97
|
# @param [Cucumber::Core::Test::Case] test_case
|
98
98
|
# @return [Array<Allure::Parameter>]
|
99
99
|
def parameters(test_case)
|
100
|
-
example_row(test_case)&.values&.map { |value| Parameter.new("argument", value) }
|
100
|
+
example_row(test_case)&.values&.map { |value| Allure::Parameter.new("argument", value) }
|
101
101
|
end
|
102
102
|
|
103
103
|
# @param [Cucumber::Core::Test::Case] test_case
|
@@ -119,7 +119,7 @@ module Allure
|
|
119
119
|
# @param [Cucumber::Core::Ast::DataTable] multiline_arg
|
120
120
|
# @return [Allure::Attachment]
|
121
121
|
def data_table_attachment(multiline_arg)
|
122
|
-
attachment = lifecycle.prepare_attachment("data-table", ContentType::CSV)
|
122
|
+
attachment = lifecycle.prepare_attachment("data-table", Allure::ContentType::CSV)
|
123
123
|
csv = multiline_arg.raw.each_with_object([]) { |row, arr| arr.push(row.to_csv) }.join("")
|
124
124
|
lifecycle.write_attachment(csv, attachment)
|
125
125
|
attachment
|
@@ -128,7 +128,7 @@ module Allure
|
|
128
128
|
# @param [String] multiline_arg
|
129
129
|
# @return [String]
|
130
130
|
def docstring_attachment(multiline_arg)
|
131
|
-
attachment = lifecycle.prepare_attachment("docstring", ContentType::TXT)
|
131
|
+
attachment = lifecycle.prepare_attachment("docstring", Allure::ContentType::TXT)
|
132
132
|
lifecycle.write_attachment(multiline_arg.content, attachment)
|
133
133
|
attachment
|
134
134
|
end
|
@@ -1,23 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "fileutils"
|
3
4
|
require_relative "cucumber_model"
|
4
5
|
|
5
|
-
module
|
6
|
+
module AllureCucumber
|
6
7
|
# Main formatter class. Translates cucumber event to allure lifecycle
|
7
8
|
class CucumberFormatter
|
9
|
+
# @return [Hash] hook handler methods
|
8
10
|
HOOK_HANDLERS = {
|
9
11
|
"Before hook" => :start_prepare_fixture,
|
10
12
|
"After hook" => :start_tear_down_fixture,
|
11
13
|
}.freeze
|
14
|
+
# @return [Hash] allure statuses mapping
|
12
15
|
ALLURE_STATUS = {
|
13
|
-
failed: Status::FAILED,
|
14
|
-
skipped: Status::SKIPPED,
|
15
|
-
passed: Status::PASSED,
|
16
|
+
failed: Allure::Status::FAILED,
|
17
|
+
skipped: Allure::Status::SKIPPED,
|
18
|
+
passed: Allure::Status::PASSED,
|
16
19
|
}.freeze
|
17
20
|
|
18
21
|
# @param [Cucumber::Configuration] config
|
19
22
|
def initialize(config)
|
20
|
-
Allure
|
23
|
+
Allure.configure do |c|
|
24
|
+
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
|
+
end
|
21
27
|
config.on_event(:test_case_started, &method(:on_test_case_started))
|
22
28
|
config.on_event(:test_step_started, &method(:on_test_step_started))
|
23
29
|
config.on_event(:test_step_finished, &method(:on_test_step_finished))
|
@@ -28,7 +34,7 @@ module Allure
|
|
28
34
|
# @param [Cucumber::Core::Events::TestCaseStarted] event
|
29
35
|
# @return [void]
|
30
36
|
def on_test_case_started(event)
|
31
|
-
lifecycle.start_test_container(TestResultContainer.new(name: event.test_case.name))
|
37
|
+
lifecycle.start_test_container(Allure::TestResultContainer.new(name: event.test_case.name))
|
32
38
|
lifecycle.start_test_case(AllureCucumberModel.test_result(event.test_case))
|
33
39
|
end
|
34
40
|
|
@@ -46,8 +52,8 @@ module Allure
|
|
46
52
|
return if prepare_world_hook?(event.test_step)
|
47
53
|
|
48
54
|
update_block = proc do |step|
|
49
|
-
step.stage = Stage::FINISHED
|
50
|
-
step.status = ALLURE_STATUS.fetch(event.result.to_sym, Status::BROKEN)
|
55
|
+
step.stage = Allure::Stage::FINISHED
|
56
|
+
step.status = ALLURE_STATUS.fetch(event.result.to_sym, Allure::Status::BROKEN)
|
51
57
|
end
|
52
58
|
step_type = hook?(event.test_step) ? "fixture" : "test_step"
|
53
59
|
|
@@ -60,9 +66,9 @@ module Allure
|
|
60
66
|
# @return [void]
|
61
67
|
def on_test_case_finished(event)
|
62
68
|
failure_details = AllureCucumberModel.failure_details(event.result)
|
63
|
-
status = ALLURE_STATUS.fetch(event.result.to_sym, Status::BROKEN)
|
69
|
+
status = ALLURE_STATUS.fetch(event.result.to_sym, Allure::Status::BROKEN)
|
64
70
|
lifecycle.update_test_case do |test_case|
|
65
|
-
test_case.stage = Stage::FINISHED
|
71
|
+
test_case.stage = Allure::Stage::FINISHED
|
66
72
|
test_case.status = event.result.failed? ? Allure::ResultUtils.status(event.result&.exception) : status
|
67
73
|
test_case.status_details.flaky = event.result.flaky?
|
68
74
|
test_case.status_details.message = failure_details[:message]
|
@@ -2,36 +2,37 @@
|
|
2
2
|
|
3
3
|
require_relative "config"
|
4
4
|
|
5
|
-
module
|
5
|
+
module AllureCucumber
|
6
|
+
# Cucumber tag parser helper methods
|
6
7
|
module TagParser
|
7
8
|
# @param [Cucumber::Core::Ast::Tag] tags
|
8
9
|
# @return [Array<Allure::Label>]
|
9
10
|
def tag_labels(tags)
|
10
11
|
tags
|
11
12
|
.reject { |tag| reserved?(tag.name) }
|
12
|
-
.map { |tag| ResultUtils.tag_label(tag.name.delete_prefix("@")) }
|
13
|
+
.map { |tag| Allure::ResultUtils.tag_label(tag.name.delete_prefix("@")) }
|
13
14
|
end
|
14
15
|
|
15
16
|
# @param [Cucumber::Core::Ast::Tag] tags
|
16
17
|
# @return [Array<Allure::Link>]
|
17
18
|
def tms_links(tags)
|
18
|
-
return [] unless
|
19
|
+
return [] unless Allure::Config.link_tms_pattern
|
19
20
|
|
20
21
|
tms_pattern = reserved_patterns[:tms]
|
21
22
|
tags
|
22
23
|
.select { |tag| tag.name.match?(tms_pattern) }
|
23
|
-
.map { |tag| tag.name.match(tms_pattern) { |match| ResultUtils.tms_link(match[:tms]) } }
|
24
|
+
.map { |tag| tag.name.match(tms_pattern) { |match| Allure::ResultUtils.tms_link(match[:tms]) } }
|
24
25
|
end
|
25
26
|
|
26
27
|
# @param [Cucumber::Core::Ast::Tag] tags
|
27
28
|
# @return [Array<Allure::Link>]
|
28
29
|
def issue_links(tags)
|
29
|
-
return [] unless
|
30
|
+
return [] unless Allure::Config.link_issue_pattern
|
30
31
|
|
31
32
|
issue_pattern = reserved_patterns[:issue]
|
32
33
|
tags
|
33
34
|
.select { |tag| tag.name.match?(issue_pattern) }
|
34
|
-
.map { |tag| tag.name.match(issue_pattern) { |match| ResultUtils.issue_link(match[:issue]) } }
|
35
|
+
.map { |tag| tag.name.match(issue_pattern) { |match| Allure::ResultUtils.issue_link(match[:issue]) } }
|
35
36
|
end
|
36
37
|
|
37
38
|
# @param [Cucumber::Core::Ast::Tag] tags
|
@@ -42,7 +43,7 @@ module Allure
|
|
42
43
|
.detect { |tag| tag.name.match?(severity_pattern) }&.name
|
43
44
|
&.match(severity_pattern)&.[](:severity) || "normal"
|
44
45
|
|
45
|
-
ResultUtils.severity_label(severity)
|
46
|
+
Allure::ResultUtils.severity_label(severity)
|
46
47
|
end
|
47
48
|
|
48
49
|
# @param [Cucumber::Core::Ast::Tag] tags
|
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.13.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: 2019-
|
11
|
+
date: 2019-09-08 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.13.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.13.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: cucumber
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,7 +51,7 @@ files:
|
|
51
51
|
- lib/allure_cucumber/cucumber_model.rb
|
52
52
|
- lib/allure_cucumber/formatter.rb
|
53
53
|
- lib/allure_cucumber/tag_parser.rb
|
54
|
-
homepage:
|
54
|
+
homepage: https://github.com/allure-framework/allure-ruby
|
55
55
|
licenses:
|
56
56
|
- Apache-2.0
|
57
57
|
metadata: {}
|
@@ -66,9 +66,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: 2.5.0
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- - "
|
69
|
+
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
71
|
+
version: '0'
|
72
72
|
requirements: []
|
73
73
|
rubygems_version: 3.0.3
|
74
74
|
signing_key:
|