allure-cucumber 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +3 -3
- data/allure-cucumber.gemspec +1 -3
- data/lib/allure-cucumber.rb +1 -3
- data/lib/allure-cucumber/dsl.rb +1 -14
- data/lib/allure-cucumber/formatter.rb +33 -31
- data/lib/allure-cucumber/version.rb +1 -1
- metadata +6 -34
- data/lib/allure-cucumber/builder.rb +0 -164
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWIzOGZmYmEzYTVhOTk4ZjczMzU0NjU5NTE5ZWFlOWMwMjc1OTExNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGNmN2NhNTRiMjg2NjA5YjA5NWFlZjc0ZGQxNDNiOTZiY2FlOTg2OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWU4YzM4Y2ZmMDVlM2E4NDYyODlhN2ZhMTAyYjRlNDA1ODBkYjQzYWM4ZDA5
|
10
|
+
OWZmZTg3MzA1YWQwYjcxZjY1ZjYxNzgzZDg5ZGJmN2RmZjQ1NDMwNjQ0NGZm
|
11
|
+
NDIxYWZmZTIwN2I5NjI4NWMzNjMxNWQyNzJiYmZkZGVhMjZlZmU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTI3OTI3Y2Q4ZTNmNzY3NjkzZjVlOGM1YzI2NGVkMDkzMjUwZTA4MzA0MGE3
|
14
|
+
YzAyMjc3NGM0ZTdkZDkyYmZlZmFmZGI3OTgwODRjM2RlZmIwMDIyMjNkYjk5
|
15
|
+
MWRkYzdiMjZlZjEwYjI3MmY2ZTBlZjRjM2ZmOGJiZmE2NDZjMzQ=
|
data/README.md
CHANGED
@@ -21,15 +21,15 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
Use `--format AllureCucumber::Formatter` while running cucumber or add it to `cucumber.yml`
|
23
23
|
|
24
|
-
By default, allure artifacts are stored in `/allure/data`. To change this set `AllureCucumber::Config.output_dir
|
24
|
+
By default, allure artifacts are stored in `/allure/data`. To change this set `AllureCucumber::Config.output_dir` in your `env.rb` file.
|
25
25
|
|
26
26
|
You can attach files to steps
|
27
27
|
|
28
|
-
|
28
|
+
```ruby
|
29
29
|
# file: features/support/env.rb
|
30
30
|
|
31
31
|
include AllureCucumber::DSL
|
32
32
|
|
33
33
|
attach_file(title, file)
|
34
|
-
|
34
|
+
```
|
35
35
|
|
data/allure-cucumber.gemspec
CHANGED
@@ -16,10 +16,8 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency 'nokogiri', '~> 1.6.0'
|
20
|
-
spec.add_dependency 'uuid'
|
21
|
-
spec.add_dependency 'mimemagic'
|
22
19
|
spec.add_dependency 'cucumber'
|
20
|
+
spec.add_dependency 'allure-ruby-api'
|
23
21
|
|
24
22
|
spec.add_development_dependency "bundler", "~> 1.5"
|
25
23
|
spec.add_development_dependency "rake"
|
data/lib/allure-cucumber.rb
CHANGED
data/lib/allure-cucumber/dsl.rb
CHANGED
@@ -1,22 +1,9 @@
|
|
1
|
-
require 'digest'
|
2
|
-
require 'mimemagic'
|
3
1
|
module AllureCucumber
|
4
2
|
module DSL
|
5
3
|
|
6
4
|
def attach_file(title, file)
|
7
5
|
@tracker = AllureCucumber::FeatureTracker.tracker
|
8
|
-
|
9
|
-
FileUtils.mkdir_p(dir)
|
10
|
-
file_extname = File.extname(file.path.downcase)
|
11
|
-
type = MimeMagic.by_path(file.path) || "text/plain"
|
12
|
-
attachment = dir.join("#{Digest::SHA256.file(file.path).hexdigest}-attachment#{(file_extname.empty?) ? '' : file_extname}")
|
13
|
-
FileUtils.cp(file.path, attachment)
|
14
|
-
AllureCucumber::Builder.add_attachment(@tracker.feature_name, @tracker.scenario_name, {
|
15
|
-
:type => type,
|
16
|
-
:title => title,
|
17
|
-
:source => attachment.basename,
|
18
|
-
:size => File.stat(attachment).size
|
19
|
-
}, @tracker.step_name)
|
6
|
+
AllureRubyApi::Builder.add_attachment(@tracker.feature_name, @tracker.scenario_name, :step => @tracker.step_name, :file => file, :title => title)
|
20
7
|
end
|
21
8
|
|
22
9
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'uuid'
|
3
|
+
require 'allure-ruby-api'
|
3
4
|
|
4
5
|
module AllureCucumber
|
5
6
|
class Formatter
|
@@ -9,13 +10,16 @@ module AllureCucumber
|
|
9
10
|
def initialize(step_mother, io, options)
|
10
11
|
dir = Pathname.new(AllureCucumber::Config.output_dir)
|
11
12
|
FileUtils.rm_rf(dir)
|
13
|
+
AllureRubyApi.configure do |c|
|
14
|
+
c.output_dir = dir
|
15
|
+
end
|
12
16
|
@tracker = AllureCucumber::FeatureTracker.create
|
13
17
|
end
|
14
18
|
|
15
19
|
def before_feature(feature)
|
16
20
|
@has_background = false
|
17
21
|
@tracker.feature_name = feature.name.gsub!(/\n/, " ")
|
18
|
-
|
22
|
+
AllureRubyApi::Builder.start_suite(@tracker.feature_name, :severity => :normal)
|
19
23
|
end
|
20
24
|
|
21
25
|
def before_background(*args)
|
@@ -36,7 +40,7 @@ module AllureCucumber
|
|
36
40
|
def scenario_name(keyword, name, file_colon_line, source_indent)
|
37
41
|
unless @scenario_outline
|
38
42
|
@tracker.scenario_name = (name.nil? || name == "") ? "Unnamed scenario" : name.split("\n")[0]
|
39
|
-
|
43
|
+
AllureRubyApi::Builder.start_test(@tracker.feature_name, @tracker.scenario_name, :feature => @tracker.feature_name, :story => @tracker.scenario_name)
|
40
44
|
post_background_steps if @has_background
|
41
45
|
else
|
42
46
|
@scenario_outline_name = (name.nil? || name == "") ? "Unnamed scenario" : name.split("\n")[0]
|
@@ -53,32 +57,37 @@ module AllureCucumber
|
|
53
57
|
unless step.background?
|
54
58
|
unless @scenario_outline
|
55
59
|
@tracker.step_name = step.name
|
56
|
-
|
60
|
+
AllureRubyApi::Builder.start_step(@tracker.feature_name, @tracker.scenario_name, @tracker.step_name)
|
57
61
|
attach_multiline_arg(step.multiline_arg)
|
58
62
|
else
|
59
|
-
@example_before_steps <<
|
63
|
+
@example_before_steps << step
|
60
64
|
end
|
61
65
|
else
|
62
|
-
@background_before_steps <<
|
66
|
+
@background_before_steps << step
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
66
70
|
def after_step(step)
|
67
71
|
unless step.background?
|
68
72
|
unless @scenario_outline
|
69
|
-
|
73
|
+
AllureRubyApi::Builder.stop_step(@tracker.feature_name, @tracker.scenario_name, @tracker.step_name, step.status.to_sym)
|
70
74
|
else
|
71
|
-
@example_after_steps <<
|
75
|
+
@example_after_steps << step
|
72
76
|
end
|
73
77
|
else
|
74
|
-
@background_after_steps <<
|
78
|
+
@background_after_steps << step
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
78
82
|
def after_steps(steps)
|
79
83
|
return if @in_background || @scenario_outline
|
80
84
|
result = { status: steps.status, exception: steps.exception }
|
81
|
-
|
85
|
+
AllureRubyApi::Builder.stop_test(@tracker.feature_name, @tracker.scenario_name, result)
|
86
|
+
end
|
87
|
+
|
88
|
+
def before_examples(*args)
|
89
|
+
@header_row = true
|
90
|
+
@in_examples = true
|
82
91
|
end
|
83
92
|
|
84
93
|
def before_examples(*args)
|
@@ -106,13 +115,13 @@ module AllureCucumber
|
|
106
115
|
@scenario_status = :passed
|
107
116
|
@exception = nil
|
108
117
|
@tracker.scenario_name = "#{@scenario_outline_name} Example: #{table_row.name}"
|
109
|
-
|
118
|
+
AllureRubyApi::Builder.start_test(@tracker.feature_name, @tracker.scenario_name, :feature => @tracker.feature_name, :story => @tracker.scenario_name)
|
110
119
|
post_background_steps if @has_background
|
111
120
|
@current_row += 1
|
112
121
|
@example_before_steps.each do |step|
|
113
|
-
@tracker.step_name = transform_step_name_for_outline(step
|
114
|
-
|
115
|
-
attach_multiline_arg(step
|
122
|
+
@tracker.step_name = transform_step_name_for_outline(step.name, @current_row)
|
123
|
+
AllureRubyApi::Builder.start_step(@tracker.feature_name, @tracker.scenario_name, @tracker.step_name)
|
124
|
+
attach_multiline_arg(step.multiline_arg)
|
116
125
|
end
|
117
126
|
end
|
118
127
|
end
|
@@ -121,14 +130,14 @@ module AllureCucumber
|
|
121
130
|
return unless @in_examples or Cucumber::Ast::OutlineTable::ExampleRow === table_row
|
122
131
|
unless @header_row
|
123
132
|
@example_after_steps.each do |step|
|
124
|
-
@tracker.step_name = transform_step_name_for_outline(step
|
133
|
+
@tracker.step_name = transform_step_name_for_outline(step.name, @current_row)
|
125
134
|
if table_row.status == :failed
|
126
135
|
@exception = table_row.exception
|
127
136
|
@scenario_status = :failed
|
128
137
|
end
|
129
|
-
|
138
|
+
AllureRubyApi::Builder.stop_step(@tracker.feature_name, @tracker.scenario_name, @tracker.step_name, step.status.to_sym)
|
130
139
|
end
|
131
|
-
|
140
|
+
AllureRubyApi::Builder.stop_test(@tracker.feature_name, @tracker.scenario_name, {:status => @scenario_status, :exception => @exception})
|
132
141
|
end
|
133
142
|
@header_row = false if @header_row
|
134
143
|
end
|
@@ -138,18 +147,11 @@ module AllureCucumber
|
|
138
147
|
end
|
139
148
|
|
140
149
|
def after_feature(feature)
|
141
|
-
|
150
|
+
AllureRubyApi::Builder.stop_suite(@tracker.feature_name)
|
142
151
|
end
|
143
152
|
|
144
153
|
def after_features(features)
|
145
|
-
|
146
|
-
dir = Pathname.new(AllureCucumber::Config.output_dir)
|
147
|
-
FileUtils.mkdir_p(dir)
|
148
|
-
out_file = dir.join("#{UUID.new.generate}-testsuite.xml")
|
149
|
-
File.open(out_file, 'w+') do |file|
|
150
|
-
file.write(xml)
|
151
|
-
end
|
152
|
-
end
|
154
|
+
AllureRubyApi::Builder.build!
|
153
155
|
end
|
154
156
|
|
155
157
|
private
|
@@ -171,14 +173,14 @@ module AllureCucumber
|
|
171
173
|
|
172
174
|
def post_background_steps
|
173
175
|
@background_before_steps.each do |step|
|
174
|
-
@tracker.step_name = "Background : #{step
|
175
|
-
|
176
|
-
attach_multiline_arg(step
|
176
|
+
@tracker.step_name = "Background : #{step.name}"
|
177
|
+
AllureRubyApi::Builder.start_step(@tracker.feature_name, @tracker.scenario_name, @tracker.step_name)
|
178
|
+
attach_multiline_arg(step.multiline_arg)
|
177
179
|
end
|
178
180
|
@background_before_steps.each do |step|
|
179
|
-
@tracker.step_name = "Background : #{step
|
180
|
-
|
181
|
-
attach_multiline_arg(step
|
181
|
+
@tracker.step_name = "Background : #{step.name}"
|
182
|
+
AllureRubyApi::Builder.stop_step(@tracker.feature_name, @tracker.scenario_name, @tracker.step_name, step.status.to_sym)
|
183
|
+
attach_multiline_arg(step.multiline_arg)
|
182
184
|
end
|
183
185
|
end
|
184
186
|
|
metadata
CHANGED
@@ -1,45 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allure-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Imran Khan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.6.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.6.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: uuid
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ! '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ! '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: mimemagic
|
14
|
+
name: cucumber
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
17
|
- - ! '>='
|
@@ -53,7 +25,7 @@ dependencies:
|
|
53
25
|
- !ruby/object:Gem::Version
|
54
26
|
version: '0'
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
28
|
+
name: allure-ruby-api
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
31
|
- - ! '>='
|
@@ -108,7 +80,6 @@ files:
|
|
108
80
|
- Rakefile
|
109
81
|
- allure-cucumber.gemspec
|
110
82
|
- lib/allure-cucumber.rb
|
111
|
-
- lib/allure-cucumber/builder.rb
|
112
83
|
- lib/allure-cucumber/dsl.rb
|
113
84
|
- lib/allure-cucumber/feature_tracker.rb
|
114
85
|
- lib/allure-cucumber/formatter.rb
|
@@ -136,5 +107,6 @@ rubyforge_project:
|
|
136
107
|
rubygems_version: 2.4.1
|
137
108
|
signing_key:
|
138
109
|
specification_version: 4
|
139
|
-
summary: allure-cucumber-0.1
|
110
|
+
summary: allure-cucumber-0.2.1
|
140
111
|
test_files: []
|
112
|
+
has_rdoc:
|
@@ -1,164 +0,0 @@
|
|
1
|
-
require 'rexml/text'
|
2
|
-
require 'nokogiri'
|
3
|
-
|
4
|
-
module AllureCucumber
|
5
|
-
|
6
|
-
class Builder
|
7
|
-
class << self
|
8
|
-
attr_accessor :suites
|
9
|
-
MUTEX = Mutex.new
|
10
|
-
|
11
|
-
def init_suites
|
12
|
-
MUTEX.synchronize {
|
13
|
-
self.suites ||= {}
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
def start_suite(title)
|
18
|
-
init_suites
|
19
|
-
MUTEX.synchronize do
|
20
|
-
puts "Starting suite : #{title}"
|
21
|
-
self.suites[title] = {
|
22
|
-
:title => title,
|
23
|
-
:start => timestamp,
|
24
|
-
:tests => {},
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def start_test(suite, test, severity = :normal)
|
30
|
-
MUTEX.synchronize do
|
31
|
-
puts "Starting test : #{test}"
|
32
|
-
self.suites[suite][:tests][test] = {
|
33
|
-
:title => test,
|
34
|
-
:start => timestamp,
|
35
|
-
:severity => severity,
|
36
|
-
:failure => nil,
|
37
|
-
:steps => {},
|
38
|
-
:attachments => []
|
39
|
-
}
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def stop_test(suite, test, result = {})
|
44
|
-
self.suites[suite][:tests][test][:steps].each do |step_title, step|
|
45
|
-
if step[:stop].nil? || step[:stop] == 0
|
46
|
-
stop_step(suite, test, step_title, result[:status])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
MUTEX.synchronize do
|
50
|
-
puts "Stopping test : #{test}"
|
51
|
-
self.suites[suite][:tests][test][:stop] = timestamp(result[:finished_at])
|
52
|
-
self.suites[suite][:tests][test][:start] = timestamp(result[:started_at])
|
53
|
-
self.suites[suite][:tests][test][:status] = result[:status]
|
54
|
-
if (result[:status].to_sym != :passed)
|
55
|
-
self.suites[suite][:tests][test][:failure] = {
|
56
|
-
:stacktrace => escape((result[:caller] || []).map { |s| s.to_s }.join("\r\n")),
|
57
|
-
:message => escape(result[:exception].to_s),
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def escape(text)
|
65
|
-
text
|
66
|
-
end
|
67
|
-
|
68
|
-
def start_step(suite, test, step, time = nil, severity = :normal)
|
69
|
-
MUTEX.synchronize do
|
70
|
-
puts "Starting step : #{step}"
|
71
|
-
self.suites[suite][:tests][test][:steps][step] = {
|
72
|
-
:title => step,
|
73
|
-
:start => timestamp(time),
|
74
|
-
:severity => severity || :normal,
|
75
|
-
:attachments => []
|
76
|
-
}
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def add_attachment(suite, test, attachment, step = nil)
|
81
|
-
attach = {
|
82
|
-
:title => attachment[:title],
|
83
|
-
:source => attachment[:source],
|
84
|
-
:type => attachment[:type],
|
85
|
-
:size => attachment[:size],
|
86
|
-
}
|
87
|
-
if step.nil?
|
88
|
-
self.suites[suite][:tests][test][:attachments] << attach
|
89
|
-
else
|
90
|
-
self.suites[suite][:tests][test][:steps][step][:attachments] << attach
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def stop_step(suite, test, step, status = :passed, time = nil)
|
95
|
-
MUTEX.synchronize do
|
96
|
-
puts "Stopping step : #{step}"
|
97
|
-
self.suites[suite][:tests][test][:steps][step][:stop] = timestamp(time)
|
98
|
-
self.suites[suite][:tests][test][:steps][step][:status] = status
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def stop_suite(title)
|
103
|
-
init_suites
|
104
|
-
MUTEX.synchronize do
|
105
|
-
puts "Stopping suite : #{title}"
|
106
|
-
self.suites[title][:stop] = timestamp
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def timestamp(time = nil)
|
111
|
-
((time || Time.now).to_f * 1000).to_i
|
112
|
-
end
|
113
|
-
|
114
|
-
def each_suite_build(&block)
|
115
|
-
suites_xml = []
|
116
|
-
self.suites.each do |suite_title, suite|
|
117
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
118
|
-
xml.send "ns2:test-suite", :start => suite[:start] || 0, :stop => suite[:stop] || 0, 'xmlns' => '', "xmlns:ns2" => "urn:model.allure.qatools.yandex.ru" do
|
119
|
-
xml.send "name", suite_title
|
120
|
-
xml.send "test-cases" do
|
121
|
-
suite[:tests].each do |test_title, test|
|
122
|
-
xml.send "test-case", :start => test[:start] || 0, :stop => test[:stop] || 0, :status => test[:status] do
|
123
|
-
xml.send "name", test_title
|
124
|
-
unless test[:failure].nil?
|
125
|
-
xml.failure do
|
126
|
-
xml.message test[:failure][:message]
|
127
|
-
xml.send "stack-trace", test[:failure][:stacktrace]
|
128
|
-
end
|
129
|
-
end
|
130
|
-
xml.steps do
|
131
|
-
test[:steps].each do |step_title, step_obj|
|
132
|
-
xml.step(:start => step_obj[:start] || 0, :stop => step_obj[:stop] || 0, :status => step_obj[:status]) do
|
133
|
-
xml.send "name", step_title
|
134
|
-
xml.attachments do
|
135
|
-
step_obj[:attachments].each do |attach|
|
136
|
-
xml.attachment :source => attach[:source], :title => attach[:title], :size => attach[:size], :type => attach[:type]
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
xml.attachments do
|
143
|
-
test[:attachments].each do |attach|
|
144
|
-
xml.attachment :source => attach[:source], :title => attach[:title], :size => attach[:size], :type => attach[:type]
|
145
|
-
end
|
146
|
-
end
|
147
|
-
xml.labels do
|
148
|
-
xml.label :name => "severity", :value => test[:severity]
|
149
|
-
end
|
150
|
-
xml.parameters
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
xml = builder.to_xml
|
157
|
-
yield suite, xml
|
158
|
-
suites_xml << xml
|
159
|
-
end
|
160
|
-
suites_xml
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|