report_builder 0.1.0 → 0.1.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/README.md +38 -19
- data/bin/report_builder +20 -1
- data/lib/report_builder.rake +4 -4
- data/lib/report_builder.rb +119 -80
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a02a160839263fa8a73421ed212a701fd99e1a9
|
4
|
+
data.tar.gz: cce242fe18d1049603c13dd7251da9d38f69a0da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f85b432d58028bdf470c660ce4ce5d027b6629897d00726a0521c74f012c89e237d35b3bfaa0733ae0b8d7b904b47504f433ec07c092809a325e0ecb86764ef8
|
7
|
+
data.tar.gz: 5b5043dbee9c937f779cd12e2d63dc105f29f40364ae245c686bee03dac2c7b5e6918f90d5c3edc491141f58de32850cd208198b1ef4038849697f741bd5f3e0
|
data/README.md
CHANGED
@@ -6,7 +6,9 @@ Ruby gem to merge Cucumber JSON reports and build single HTML Test Report
|
|
6
6
|
## Installation
|
7
7
|
|
8
8
|
```bash
|
9
|
+
|
9
10
|
gem install report_builder
|
11
|
+
|
10
12
|
```
|
11
13
|
|
12
14
|
## Information
|
@@ -27,7 +29,9 @@ gem install report_builder
|
|
27
29
|
| report_path | [String] | 'test_report' | output file path with file name without extension |
|
28
30
|
| report_types | [Array] | [:html] | :json, :html (output file types) |
|
29
31
|
| report_tabs | [Array] | [:overview, :features] | :overview, :features, :scenarios, :errors (tabs to build) |
|
32
|
+
| report_title | [String] | 'Test Results' | report and html title |
|
30
33
|
| compress_images | [Boolean] | false | true / false (If true, the size of HTML report is reduced but takes more time to build report) |
|
34
|
+
| additional_info | [Hash] | {} | additional info for report summary |
|
31
35
|
|
32
36
|
### Code Examples:
|
33
37
|
|
@@ -38,10 +42,12 @@ gem install report_builder
|
|
38
42
|
# Ex 1:
|
39
43
|
ReportBuilder.configure do |config|
|
40
44
|
config.json_path = 'cucumber_sample/logs'
|
41
|
-
config.report_path = '
|
45
|
+
config.report_path = 'my_test_report'
|
42
46
|
config.report_types = [:json, :html]
|
43
47
|
config.report_tabs = [:overview, :features, :scenarios, :errors]
|
48
|
+
config.report_title = 'My Test Results'
|
44
49
|
config.compress_images = false
|
50
|
+
config.additional_info = {browser: 'Chrome', environment: 'Stage 5'}
|
45
51
|
end
|
46
52
|
|
47
53
|
ReportBuilder.build_report
|
@@ -49,10 +55,12 @@ gem install report_builder
|
|
49
55
|
# Ex 2:
|
50
56
|
options = {
|
51
57
|
json_path: 'cucumber_sample/logs',
|
52
|
-
report_path: '
|
58
|
+
report_path: 'my_test_report',
|
53
59
|
report_types: ['json', 'html'],
|
54
|
-
report_tabs: [ 'overview', 'features', 'scenarios', 'errors']
|
55
|
-
|
60
|
+
report_tabs: [ 'overview', 'features', 'scenarios', 'errors'],
|
61
|
+
report_title: 'My Test Results',
|
62
|
+
compress_images: false,
|
63
|
+
additional_info: {'browser' => 'Chrome', 'environment' => 'Stage 5'}
|
56
64
|
}
|
57
65
|
|
58
66
|
ReportBuilder.build_report options
|
@@ -61,37 +69,48 @@ gem install report_builder
|
|
61
69
|
|
62
70
|
### CLI Options:
|
63
71
|
|
64
|
-
| Option | Values
|
65
|
-
|
66
|
-
| -s, --source | x,y,z
|
67
|
-
| -o, --out | [PATH]NAME
|
68
|
-
| -f, --format | x,y,z
|
69
|
-
| -t, --tabs | x,y,z
|
70
|
-
| -c, --compress |
|
71
|
-
| -
|
72
|
-
| -
|
72
|
+
| Option | Values | Explanation |
|
73
|
+
|----------------|-------------|----------------------------------------------------------|
|
74
|
+
| -s, --source | x,y,z | List of json path or files |
|
75
|
+
| -o, --out | [PATH]NAME | Report path with name without extension |
|
76
|
+
| -f, --format | x,y,z | List of report format - html,json |
|
77
|
+
| -t, --tabs | x,y,z | List of report tabs - overview,features,scenarios,errors |
|
78
|
+
| -c, --compress | | Reduce report size if embedding images |
|
79
|
+
| -T, --title | TITLE | Report title |
|
80
|
+
| -I, --info | a:x,b:y,c:z | List of additional info about test - key:value |
|
81
|
+
| -h, --help | | Show available command line switches |
|
82
|
+
| -v, --version | | Show gem version |
|
73
83
|
|
74
84
|
### CLI Example:
|
75
85
|
|
76
86
|
```bash
|
87
|
+
|
77
88
|
report_builder
|
78
89
|
report_builder -s 'path/of/json/files/dir'
|
79
|
-
report_builder -s 'path/of/json/files/dir' -o
|
90
|
+
report_builder -s 'path/of/json/files/dir' -o my_report_file
|
91
|
+
report_builder -s 'path/of/json/files/dir' -o my_report_file -t overview,features,scenarios,errors
|
92
|
+
|
80
93
|
```
|
81
94
|
|
82
95
|
### Rake Example:
|
83
96
|
|
84
97
|
Add in Rakefile
|
98
|
+
|
85
99
|
```ruby
|
86
|
-
|
87
|
-
|
100
|
+
|
101
|
+
require 'report_builder'
|
102
|
+
load 'report_builder.rake'
|
103
|
+
|
88
104
|
```
|
105
|
+
|
89
106
|
Then run rake task report_builder
|
90
107
|
|
91
108
|
```bash
|
92
|
-
|
93
|
-
|
94
|
-
|
109
|
+
|
110
|
+
rake report_builder
|
111
|
+
rake report_builder['path/of/json/files/dir']
|
112
|
+
rake report_builder['path/of/json/files/dir','report_file']
|
113
|
+
|
95
114
|
```
|
96
115
|
|
97
116
|
## Contributing
|
data/bin/report_builder
CHANGED
@@ -3,7 +3,15 @@
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'report_builder'
|
5
5
|
|
6
|
-
options = {
|
6
|
+
options = {
|
7
|
+
:json_path => nil,
|
8
|
+
:report_path => 'test_report',
|
9
|
+
:report_types => [:html],
|
10
|
+
:report_tabs => [:overview, :features],
|
11
|
+
:report_title => 'Test Results',
|
12
|
+
:compress_images => false,
|
13
|
+
:additional_info => {}
|
14
|
+
}
|
7
15
|
|
8
16
|
opt_parser = OptionParser.new do |opts|
|
9
17
|
opts.banner = "Usage: \n report_builder [options]"
|
@@ -29,6 +37,17 @@ opt_parser = OptionParser.new do |opts|
|
|
29
37
|
options[:compress_images] = compress
|
30
38
|
end
|
31
39
|
|
40
|
+
opts.on('-T', '--title TITLE', String, 'Report title') do |report_title|
|
41
|
+
options[:report_title] = report_title
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on('-I','--info a:x,b:y,c:z', Array, 'List of additional info') do |list|
|
45
|
+
list.each do |i|
|
46
|
+
key, value = i.split(':')
|
47
|
+
options[:additional_info][key] = value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
32
51
|
opts.separator 'Common options:'
|
33
52
|
|
34
53
|
opts.on_tail('-h', '--help', 'Show help') do
|
data/lib/report_builder.rake
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
desc '
|
2
|
-
task :report_builder, [:json_path, :report_path
|
3
|
-
args.with_defaults(:json_path => nil, :report_path => 'test_report'
|
4
|
-
options = {:json_path => args.json_path, :report_path => args.report_path
|
1
|
+
desc 'Sample rake task to build report'
|
2
|
+
task :report_builder, [:json_path, :report_path] do |t, args|
|
3
|
+
args.with_defaults(:json_path => nil, :report_path => 'test_report')
|
4
|
+
options = {:json_path => args.json_path, :report_path => args.report_path}
|
5
5
|
ReportBuilder.build_report options
|
6
6
|
end
|
data/lib/report_builder.rb
CHANGED
@@ -20,12 +20,14 @@ class ReportBuilder
|
|
20
20
|
# report_builder:
|
21
21
|
#
|
22
22
|
# ReportBuilder.configure do |config|
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
23
|
+
# config.json_path = 'cucumber_sample/logs'
|
24
|
+
# config.report_path = 'my_test_report'
|
25
|
+
# config.report_types = [:json, :html]
|
26
|
+
# config.report_tabs = [:overview, :features, :scenarios, :errors]
|
27
|
+
# config.report_title = 'My Test Results'
|
28
|
+
# config.compress_images = false
|
29
|
+
# config.additional_info = {browser: 'Chrome', environment: 'Stage 5'}
|
30
|
+
# end
|
29
31
|
#
|
30
32
|
# ReportBuilder.build_report
|
31
33
|
#
|
@@ -46,10 +48,12 @@ class ReportBuilder
|
|
46
48
|
#
|
47
49
|
# Ex: ReportBuilder.configure do |config|
|
48
50
|
# config.json_path = 'cucumber_sample/logs'
|
49
|
-
# config.report_path = '
|
51
|
+
# config.report_path = 'my_test_report'
|
50
52
|
# config.report_types = [:JSON, :HTML]
|
51
53
|
# config.report_tabs = [:Overview, :Features, :Scenarios, :Errors]
|
54
|
+
# config.report_title = 'My Test Results'
|
52
55
|
# config.compress_images = true
|
56
|
+
# config.additional_info = {Browser: 'Chrome', Environment: 'Stage 5'}
|
53
57
|
# end
|
54
58
|
#
|
55
59
|
def self.configure
|
@@ -58,7 +62,9 @@ class ReportBuilder
|
|
58
62
|
report_path: 'test_report', # [String] Output file path with name
|
59
63
|
report_types: [:html], # [Array] Output file types to build, [:json, :html] or ['html', 'json']
|
60
64
|
report_tabs: [:overview, :features], # [Array] Tabs to build, [:overview, :features, :scenarios, :errors] or ['overview', 'features', 'scenarios', 'errors']
|
61
|
-
|
65
|
+
report_title: 'Test Results', # [String] Report and html title
|
66
|
+
compress_images: false, # [Boolean] Set true to reducing the size of HTML report, Note: If true, takes more time to build report
|
67
|
+
additional_info: {} # [Hash] Additional info for report summary
|
62
68
|
)
|
63
69
|
yield default_options if block_given?
|
64
70
|
@options = default_options.marshal_dump
|
@@ -69,10 +75,12 @@ class ReportBuilder
|
|
69
75
|
#
|
70
76
|
# Ex: options = {
|
71
77
|
# json_path: 'cucumber_sample/logs',
|
72
|
-
# report_path: '
|
78
|
+
# report_path: 'my_test_report',
|
73
79
|
# report_types: ['json', 'html'],
|
74
|
-
# report_tabs: [ 'overview', 'features', 'scenarios', 'errors']
|
75
|
-
#
|
80
|
+
# report_tabs: [ 'overview', 'features', 'scenarios', 'errors'],
|
81
|
+
# report_title: 'My Test Results',
|
82
|
+
# compress_images: false,
|
83
|
+
# additional_info: {'browser' => 'Chrome', 'environment' => 'Stage 5'}
|
76
84
|
# }
|
77
85
|
#
|
78
86
|
# ReportBuilder.build_report options
|
@@ -98,31 +106,34 @@ class ReportBuilder
|
|
98
106
|
|
99
107
|
all_scenarios = scenarios all_features
|
100
108
|
all_steps = steps all_scenarios
|
109
|
+
all_tags = tags all_scenarios
|
101
110
|
total_time = total_time all_features
|
102
111
|
feature_data = data all_features
|
103
112
|
scenario_data = data all_scenarios
|
104
113
|
step_data = data all_steps
|
105
114
|
|
106
115
|
File.open(@options[:report_path] + '.html', 'w:UTF-8') do |file|
|
107
|
-
@builder = Builder::XmlMarkup.new(:
|
116
|
+
@builder = Builder::XmlMarkup.new(target: file, indent: 0)
|
108
117
|
@builder.declare!(:DOCTYPE, :html)
|
109
118
|
@builder << '<html>'
|
110
119
|
|
111
120
|
@builder.head do
|
112
121
|
@builder.meta(charset: 'UTF-8')
|
113
|
-
@builder.title
|
122
|
+
@builder.title @options[:report_title]
|
114
123
|
|
115
|
-
@builder.style(:
|
124
|
+
@builder.style(type: 'text/css') do
|
116
125
|
@builder << File.read(File.dirname(__FILE__) + '/../vendor/assets/stylesheets/jquery-ui.min.css')
|
117
126
|
COLOR.each do |color|
|
118
127
|
@builder << ".#{color[0].to_s}{background:#{color[1]};color:#434348;padding:2px}"
|
119
128
|
end
|
120
|
-
@builder << '.summary{border: 1px solid #c5c5c5;border-radius:4px;
|
129
|
+
@builder << '.summary{margin-bottom:4px;border: 1px solid #c5c5c5;border-radius:4px;background:#f1f1f1;color:#434348;padding:4px;overflow:hidden;vertical-align:bottom;}'
|
130
|
+
@builder << '.summary .results{text-align:right;float:right;}'
|
131
|
+
@builder << '.summary .info{text-align:left;float:left;}'
|
121
132
|
@builder << '.data_table{border-collapse: collapse;} .data_table td{padding: 5px; border: 1px solid #ddd;}'
|
122
133
|
@builder << '.ui-tooltip{background: black; color: white; font-size: 12px; padding: 2px 4px; border-radius: 20px; box-shadow: 0 0 7px black;}'
|
123
134
|
end
|
124
135
|
|
125
|
-
@builder.script(:
|
136
|
+
@builder.script(type: 'text/javascript') do
|
126
137
|
%w(jquery-min jquery-ui.min highcharts highcharts-3d).each do |js|
|
127
138
|
@builder << File.read(File.dirname(__FILE__) + '/../vendor/assets/javascripts/' + js + '.js')
|
128
139
|
end
|
@@ -141,41 +152,57 @@ class ReportBuilder
|
|
141
152
|
|
142
153
|
@builder << '<body>'
|
143
154
|
|
144
|
-
@builder.
|
145
|
-
@builder
|
146
|
-
|
147
|
-
@builder << '
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
@
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
155
|
+
@builder.div(class: 'summary') do
|
156
|
+
@builder.span(class: 'info') do
|
157
|
+
info = @options[:additional_info].empty?
|
158
|
+
@builder << '<br/> ' if info
|
159
|
+
@builder.span(style: "font-size:#{info ? 36 : 18 }px;font-weight: bold;") do
|
160
|
+
@builder << @options[:report_title]
|
161
|
+
end
|
162
|
+
@options[:additional_info].each do |l|
|
163
|
+
@builder << '<br/>' + l[0].to_s.capitalize + ' : ' + l[1].to_s
|
164
|
+
end
|
165
|
+
end if @options[:additional_info].is_a? Hash
|
166
|
+
@builder.span(class: 'results') do
|
167
|
+
s = all_features.size
|
168
|
+
@builder << s.to_s + " feature#{'s' if s > 1} ("
|
169
|
+
feature_data.each do |data|
|
170
|
+
@builder << ' ' + data[:count].to_s + ' ' + data[:name]
|
171
|
+
end
|
172
|
+
s = all_scenarios.size
|
173
|
+
@builder << ')<br/>' + s.to_s + " scenario#{'s' if s > 1} ("
|
174
|
+
scenario_data.each do |data|
|
175
|
+
@builder << ' ' + data[:count].to_s + ' ' + data[:name]
|
176
|
+
end
|
177
|
+
s = all_steps.size
|
178
|
+
@builder << ')<br/>' + s.to_s + " step#{'s' if s > 1} ("
|
179
|
+
step_data.each do |data|
|
180
|
+
@builder << ' ' + data[:count].to_s + ' ' + data[:name]
|
181
|
+
end
|
182
|
+
@builder << ')<br/>🕐 ' + duration(total_time).to_s
|
156
183
|
end
|
157
|
-
@builder << ') ~ ' + duration(total_time).to_s
|
158
184
|
end
|
159
185
|
|
160
|
-
@builder.div(:
|
186
|
+
@builder.div(id: 'results') do
|
161
187
|
build_menu @options[:report_tabs]
|
162
188
|
|
163
|
-
@builder.div(:
|
189
|
+
@builder.div(id: 'overviewTab') do
|
164
190
|
@builder << "<div id='featurePieChart' style=\"float:left;width:33%\"></div>"
|
165
191
|
@builder << "<div id='scenarioPieChart' style=\"display:inline-block;width:33%\"></div>"
|
166
192
|
@builder << "<div id='stepPieChart' style=\"float:right;width:33%\"></div>"
|
167
193
|
end if @options[:report_tabs].include? 'overview'
|
168
194
|
|
169
|
-
@builder.div(:
|
170
|
-
|
195
|
+
@builder.div(id: 'featuresTab') do
|
196
|
+
build_tags_drop_down(all_tags)
|
197
|
+
@builder.div(id: 'features') do
|
171
198
|
all_features.each_with_index do |feature, n|
|
172
199
|
@builder.h3(style: "background:#{COLOR[feature['status'].to_sym]}") do
|
173
|
-
@builder.span(:
|
200
|
+
@builder.span(class: feature['status']) do
|
174
201
|
@builder << "<strong>#{feature['keyword']}</strong> #{feature['name']} (#{duration(feature['duration'])})"
|
175
202
|
end
|
176
203
|
end
|
177
204
|
@builder.div do
|
178
|
-
@builder.div(:
|
205
|
+
@builder.div(id: "feature#{n}") do
|
179
206
|
feature['elements'].each{|scenario| build_scenario scenario}
|
180
207
|
end
|
181
208
|
end
|
@@ -184,36 +211,17 @@ class ReportBuilder
|
|
184
211
|
@builder << "<div id='featureTabPieChart'></div>"
|
185
212
|
end if @options[:report_tabs].include? 'features'
|
186
213
|
|
187
|
-
@builder.div(:
|
188
|
-
all_tags
|
189
|
-
@builder.div(
|
190
|
-
@builder << '<strong>Tag: </strong>'
|
191
|
-
@builder.select(class: 'select-tags') do
|
192
|
-
@builder.option(value: 'scenario-all') do
|
193
|
-
@builder << 'All'
|
194
|
-
end
|
195
|
-
all_tags.each do |tag|
|
196
|
-
@builder.option(value: tag.gsub('@','tag-')) do
|
197
|
-
@builder << tag
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
@builder.script do
|
202
|
-
@builder << '$("#scenariosTab .select-tags").change(function(){var val = $(this).val();$("#scenariosTab .scenario-all").next().hide();
|
203
|
-
$("#scenariosTab .scenario-all").hide();$("#scenariosTab ." + val).show();$("#scenariosTab #count").each(function(){
|
204
|
-
status = $(this).parent().parent().prop("className");$("#scenariosTab ." + status + " #count").html(
|
205
|
-
$("#scenariosTab #" + status + " ." + val).length);});});'
|
206
|
-
end
|
207
|
-
end unless all_tags.empty?
|
208
|
-
@builder.div(:id => 'status') do
|
214
|
+
@builder.div(id: 'scenariosTab') do
|
215
|
+
build_tags_drop_down(all_tags)
|
216
|
+
@builder.div(id: 'status') do
|
209
217
|
all_scenarios.group_by{|scenario| scenario['status']}.each do |data|
|
210
218
|
@builder.h3(style: "background:#{COLOR[data[0].to_sym]}") do
|
211
|
-
@builder.span(:
|
219
|
+
@builder.span(class: data[0]) do
|
212
220
|
@builder << "<strong>#{data[0].capitalize} scenarios (Count: <span id='count'>#{data[1].size}</span>)</strong>"
|
213
221
|
end
|
214
222
|
end
|
215
223
|
@builder.div do
|
216
|
-
@builder.div(:
|
224
|
+
@builder.div(id: data[0]) do
|
217
225
|
data[1].each{|scenario| build_scenario scenario}
|
218
226
|
end
|
219
227
|
end
|
@@ -222,19 +230,27 @@ class ReportBuilder
|
|
222
230
|
@builder << "<div id='scenarioTabPieChart'></div>"
|
223
231
|
end if @options[:report_tabs].include? 'scenarios'
|
224
232
|
|
225
|
-
@builder.div(:
|
233
|
+
@builder.div(id: 'errorsTab') do
|
226
234
|
@builder.ol do
|
227
235
|
all_scenarios.each{|scenario| build_error_list scenario}
|
228
236
|
end
|
229
237
|
end if @options[:report_tabs].include? 'errors'
|
230
238
|
end
|
231
239
|
|
232
|
-
@builder.script(:
|
240
|
+
@builder.script(type: 'text/javascript') do
|
233
241
|
@builder << pie_chart_js('featurePieChart', 'Features', feature_data) if @options[:report_tabs].include? 'overview'
|
234
242
|
@builder << donut_js('featureTabPieChart', 'Features', feature_data) if @options[:report_tabs].include? 'features'
|
235
243
|
@builder << pie_chart_js('scenarioPieChart', 'Scenarios', scenario_data) if @options[:report_tabs].include? 'overview'
|
236
244
|
@builder << donut_js('scenarioTabPieChart', 'Scenarios', scenario_data) if @options[:report_tabs].include? 'scenarios'
|
237
245
|
@builder << pie_chart_js('stepPieChart', 'Steps', step_data) if @options[:report_tabs].include? 'overview'
|
246
|
+
unless all_tags.empty?
|
247
|
+
@builder << '$("#featuresTab .select-tags").change(function(){var val = $(this).val();$("#featuresTab .scenario-all").next().hide();
|
248
|
+
$("#featuresTab .scenario-all").hide();$("#featuresTab ." + val).show();});' if @options[:report_tabs].include? 'features'
|
249
|
+
@builder << '$("#scenariosTab .select-tags").change(function(){var val = $(this).val();$("#scenariosTab .scenario-all").next().hide();
|
250
|
+
$("#scenariosTab .scenario-all").hide();$("#scenariosTab ." + val).show();$("#scenariosTab #count").each(function(){
|
251
|
+
status = $(this).parent().parent().prop("className");$("#scenariosTab ." + status + " #count").html(
|
252
|
+
$("#scenariosTab #" + status + " ." + val).length);});});' if @options[:report_tabs].include? 'scenarios'
|
253
|
+
end
|
238
254
|
end
|
239
255
|
|
240
256
|
@builder << '</body>'
|
@@ -250,7 +266,7 @@ class ReportBuilder
|
|
250
266
|
@builder.ul do
|
251
267
|
tabs.each do |tab|
|
252
268
|
@builder.li do
|
253
|
-
@builder.a(:
|
269
|
+
@builder.a(href: "##{tab}Tab") do
|
254
270
|
@builder << tab.capitalize
|
255
271
|
end
|
256
272
|
end
|
@@ -261,7 +277,7 @@ class ReportBuilder
|
|
261
277
|
def self.build_scenario(scenario)
|
262
278
|
tags = (scenario['tags'] ? scenario['tags'].map{|tag| tag['name']}.join(' ') : '')
|
263
279
|
@builder.h3(style: "background:#{COLOR[scenario['status'].to_sym]}", title: tags, class: 'scenario-all ' + tags.gsub('@','tag-')) do
|
264
|
-
@builder.span(:
|
280
|
+
@builder.span(class: scenario['status']) do
|
265
281
|
@builder << "<strong>#{scenario['keyword']}</strong> #{scenario['name']} (#{duration(scenario['duration'])})"
|
266
282
|
end
|
267
283
|
end
|
@@ -281,7 +297,7 @@ class ReportBuilder
|
|
281
297
|
end
|
282
298
|
|
283
299
|
def self.build_step(step, scenario_keyword)
|
284
|
-
@builder.div(:
|
300
|
+
@builder.div(class: step['status']) do
|
285
301
|
@builder << "<strong>#{step['keyword']}</strong> #{step['name']} (#{duration(step['duration'])})"
|
286
302
|
end
|
287
303
|
build_data_table step['rows']
|
@@ -296,7 +312,7 @@ class ReportBuilder
|
|
296
312
|
end
|
297
313
|
|
298
314
|
def self.build_data_table(rows)
|
299
|
-
@builder.table(:
|
315
|
+
@builder.table(class: 'data_table') do
|
300
316
|
rows.each do |row|
|
301
317
|
@builder.tr do
|
302
318
|
row['cells'].each do |cell|
|
@@ -313,11 +329,27 @@ class ReportBuilder
|
|
313
329
|
end if outputs.is_a?(Array)
|
314
330
|
end
|
315
331
|
|
332
|
+
def self.build_tags_drop_down(tags)
|
333
|
+
@builder.div(style: 'text-align:center;padding:5px;') do
|
334
|
+
@builder << '<strong>Tag: </strong>'
|
335
|
+
@builder.select(class: 'select-tags') do
|
336
|
+
@builder.option(value: 'scenario-all') do
|
337
|
+
@builder << 'All'
|
338
|
+
end
|
339
|
+
tags.each do |tag|
|
340
|
+
@builder.option(value: tag.gsub('@','tag-')) do
|
341
|
+
@builder << tag
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end if tags.is_a?(Array)
|
346
|
+
end
|
347
|
+
|
316
348
|
def self.build_step_error(step)
|
317
349
|
if step['status'] == 'failed' && step['result']['error_message']
|
318
350
|
@builder << "<strong style=color:#{COLOR[:failed]}>Error: </strong>"
|
319
351
|
error = step['result']['error_message'].split("\n")
|
320
|
-
@builder.span(:
|
352
|
+
@builder.span(style: "color:#{COLOR[:failed]}") do
|
321
353
|
error[0..-3].each do |line|
|
322
354
|
@builder << line + '<br/>'
|
323
355
|
end
|
@@ -331,7 +363,7 @@ class ReportBuilder
|
|
331
363
|
if hook['status'] == 'failed'
|
332
364
|
@builder << "<strong style=color:#{COLOR[:failed]}>Error: </strong>"
|
333
365
|
error = hook['result']['error_message'].split("\n")
|
334
|
-
@builder.span(:
|
366
|
+
@builder.span(style: "color:#{COLOR[:failed]}") do
|
335
367
|
error[0..-2].each do |line|
|
336
368
|
@builder << line + '<br/>'
|
337
369
|
end
|
@@ -344,7 +376,7 @@ class ReportBuilder
|
|
344
376
|
if hook['result']['error_message']
|
345
377
|
@builder << "<strong style=color:#{COLOR[:failed]}>Error: </strong>"
|
346
378
|
error = hook['result']['error_message'].split("\n")
|
347
|
-
@builder.span(:
|
379
|
+
@builder.span(style: "color:#{COLOR[:failed]}") do
|
348
380
|
(scenario_keyword == 'Scenario Outline' ? error[0..-8] : error[0..-5]).each do |line|
|
349
381
|
@builder << line + '<br/>'
|
350
382
|
end
|
@@ -359,9 +391,9 @@ class ReportBuilder
|
|
359
391
|
embeddings.each do |embedding|
|
360
392
|
id = "embedding_#{@embedding_count}"
|
361
393
|
if embedding['mime_type'] =~ /^image\/(png|gif|jpg|jpeg)/
|
362
|
-
@builder.span(:
|
363
|
-
@builder.a(:
|
364
|
-
@builder.span(:
|
394
|
+
@builder.span(class: 'image') do
|
395
|
+
@builder.a(href: '', style: 'text-decoration: none;', onclick: "img=document.getElementById('#{id}');img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false") do
|
396
|
+
@builder.span(style: "color: #{COLOR[:output]}; font-weight: bold; border-bottom: 1px solid #{COLOR[:output]};") do
|
365
397
|
@builder << 'Screenshot'
|
366
398
|
end
|
367
399
|
end
|
@@ -369,10 +401,10 @@ class ReportBuilder
|
|
369
401
|
@options[:compress_images] ? build_unique_image(embedding, id) : build_image(embedding,id) rescue puts 'Image embedding failed!'
|
370
402
|
end
|
371
403
|
elsif embedding['mime_type'] =~ /^text\/plain/
|
372
|
-
@builder.span(:
|
404
|
+
@builder.span(class: 'link') do
|
373
405
|
src = Base64.decode64(embedding['data'])
|
374
|
-
@builder.a(:
|
375
|
-
@builder.span(:
|
406
|
+
@builder.a(id: id, style: 'text-decoration: none;', href: src, title: 'Link') do
|
407
|
+
@builder.span(style: "color: #{COLOR[:output]}; font-weight: bold; border-bottom: 1px solid #{COLOR[:output]};") do
|
376
408
|
@builder << src
|
377
409
|
end
|
378
410
|
end
|
@@ -391,7 +423,7 @@ class ReportBuilder
|
|
391
423
|
else
|
392
424
|
@images << image
|
393
425
|
klass = "image_#{@images.size - 1}"
|
394
|
-
@builder.style(:
|
426
|
+
@builder.style(type: 'text/css') do
|
395
427
|
begin
|
396
428
|
src = Base64.decode64(image['data'])
|
397
429
|
src = 'data:' + image['mime_type'] + ';base64,' + src unless src =~ /^data:image\/(png|gif|jpg|jpeg);base64,/
|
@@ -423,7 +455,7 @@ class ReportBuilder
|
|
423
455
|
next unless before['status'] == 'failed'
|
424
456
|
@builder.li do
|
425
457
|
error = before['result']['error_message'].split("\n")
|
426
|
-
@builder.span(:
|
458
|
+
@builder.span(style: "color:#{COLOR[:failed]}") do
|
427
459
|
error[0..-2].each do |line|
|
428
460
|
@builder << line + '<br/>'
|
429
461
|
end
|
@@ -437,7 +469,7 @@ class ReportBuilder
|
|
437
469
|
next unless after['status'] == 'failed'
|
438
470
|
@builder.li do
|
439
471
|
error = after['result']['error_message'].split("\n")
|
440
|
-
@builder.span(:
|
472
|
+
@builder.span(style: "color:#{COLOR[:failed]}") do
|
441
473
|
(scenario['keyword'] == 'Scenario Outline' ? error[0..-8] : error[0..-5]).each do |line|
|
442
474
|
@builder << line + '<br/>'
|
443
475
|
end
|
@@ -449,7 +481,7 @@ class ReportBuilder
|
|
449
481
|
next unless step['status'] == 'failed' && step['result']['error_message']
|
450
482
|
@builder.li do
|
451
483
|
error = step['result']['error_message'].split("\n")
|
452
|
-
@builder.span(:
|
484
|
+
@builder.span(style: "color:#{COLOR[:failed]}") do
|
453
485
|
error[0..-3].each do |line|
|
454
486
|
@builder << line + '<br/>'
|
455
487
|
end
|
@@ -462,7 +494,7 @@ class ReportBuilder
|
|
462
494
|
next unless after['status'] == 'failed'
|
463
495
|
@builder.li do
|
464
496
|
error = after['result']['error_message'].split("\n")
|
465
|
-
@builder.span(:
|
497
|
+
@builder.span(style: "color:#{COLOR[:failed]}") do
|
466
498
|
error[0..-2].each do |line|
|
467
499
|
@builder << line + '<br/>'
|
468
500
|
end
|
@@ -550,6 +582,12 @@ class ReportBuilder
|
|
550
582
|
end.flatten
|
551
583
|
end
|
552
584
|
|
585
|
+
def self.tags(scenarios)
|
586
|
+
scenarios.map do |scenario|
|
587
|
+
scenario['tags'] ? scenario['tags'].map{|t| t['name']} : []
|
588
|
+
end.flatten.uniq
|
589
|
+
end
|
590
|
+
|
553
591
|
def self.files(path)
|
554
592
|
files = if path.is_a? String
|
555
593
|
(path =~ /\.json$/) ? [path] : Dir.glob("#{path}/*.json")
|
@@ -629,5 +667,6 @@ class ReportBuilder
|
|
629
667
|
:build_menu, :build_output, :build_embedding,
|
630
668
|
:build_error_list, :build_step_error,
|
631
669
|
:build_hook_error, :build_step_hook_error,
|
632
|
-
:build_unique_image, :build_image
|
670
|
+
:build_unique_image, :build_image,
|
671
|
+
:build_data_table, :tags, :build_tags_drop_down
|
633
672
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: report_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajat Thareja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -70,7 +70,7 @@ homepage: https://github.com/rajatthareja/ReportBuilder
|
|
70
70
|
licenses:
|
71
71
|
- MIT
|
72
72
|
metadata: {}
|
73
|
-
post_install_message:
|
73
|
+
post_install_message: Happy reporting!
|
74
74
|
rdoc_options: []
|
75
75
|
require_paths:
|
76
76
|
- lib
|